CCControlButton 按钮

2篇1章1节:数据的基本概念以及 R 中的数据结构、向量与矩阵的创建及运算 本文详细介绍了R语言中常见的数据结构的向量和矩阵。通过掌握这些数据结构的基本概念和操作技巧,可以更高效地处理和分析数据。 阅读详情

新建工程名为testButton。

修改HelloWorldScene.h

#ifndef __HELLOWORLD_SCENE_H__

#define __HELLOWORLD_SCENE_H__


#include "cocos2d.h"

#include "cocos-ext.h"

using namespace cocos2d::extension;

class HelloWorld : public cocos2d::CCLayer

{

public:

    // Method 'init' in cocos2d-x returns bool, instead of 'id' in cocos2d-iphone (an object pointer)

    virtual bool init();


    // there's no 'id' in cpp, so we recommend to return the class instance pointer

    static cocos2d::CCScene* scene();

    

    //按钮按下事件

    void touchDownAction(CCObject *sender,CCControlEvent controlEvent);

    

    //按钮在其内部抬起事件回调

    void touchUpInsideAction(CCObject *sender,CCControlEvent controlEvent);

    

    //按钮在其外部抬起事件回调

    void touchUpOutsideAction(CCObject *sender,CCControlEvent controlEvent);

    // preprocessor macro for "static create()" constructor ( node() deprecated )

    CREATE_FUNC(HelloWorld);

};


#endif // __HELLOWORLD_SCENE_H__

修改HelloWorldScene.cpp


#include "HelloWorldScene.h"

#include "SimpleAudioEngine.h"


using namespace cocos2d;

using namespace CocosDenshion;


CCScene* HelloWorld::scene()

{

    // 'scene' is an autorelease object

    CCScene *scene = CCScene::create();

    

    // 'layer' is an autorelease object

    HelloWorld *layer = HelloWorld::create();


    // add layer as a child to scene

    scene->addChild(layer);


    // return the scene

    return scene;

}


// on "init" you need to initialize your instance

bool HelloWorld::init()

{

    //////////////////////////////

    // 1. super init first

    if ( !CCLayer::init() )

    {

        return false;

    }


    CCLabelTTF *titleButton=CCLabelTTF::create("未选中文字", "Marker Felt", 25);

    CCControlButton *btn=CCControlButton::create(titleButton, CCScale9Sprite::create("button.png"));

    btn->setPosition(240,170);

    

    //按钮被选中后背景图响应的状态

    btn->setBackgroundSpriteForState(CCScale9Sprite::create("buttonHighlighted.png"), CCControlStateHighlighted);

    //按钮被选中后文字颜色响应的状态

    btn->setTitleColorForState(ccc3(255, 0, 0), CCControlStateHighlighted);

    //按钮被选中后文字响应的状态

    btn->setTitleForState(CCString::create("选中文字"), CCControlStateHighlighted);

    addChild(btn);

    

    

    //按钮按下事件回调

    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDownAction), CCControlEventTouchDown);

    //按钮在其内部事件回调

    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchUpInsideAction), CCControlEventTouchUpInside);

    //按钮在其外部事件回调

    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchUpOutsideAction), CCControlEventTouchUpOutside);

    

    //用于显示按钮状态

    CCLabelTTF *titleButtonState=CCLabelTTF::create("", "Marker Felt", 25);

    addChild(titleButtonState,0,923);

    titleButtonState->setPosition(ccp(240,220));

    return true;

}


//按钮按下事件

void HelloWorld::touchDownAction(CCObject *sender,CCControlEvent controlEvent)

{

    CCLabelTTF *m_pDisplayValueLabel=(CCLabelTTF*)this->getChildByTag(923);

    m_pDisplayValueLabel->setString(CCString::createWithFormat("按下")->getCString());

}


//按钮在其内部抬起事件回调

void HelloWorld::touchUpInsideAction(CCObject *sender,CCControlEvent controlEvent)

{

    CCLabelTTF *m_pDisplayValueLabel=(CCLabelTTF*)this->getChildByTag(923);

    m_pDisplayValueLabel->setString(CCString::createWithFormat("内部抬起")->getCString());

}


//按钮在其外部抬起事件回调

void HelloWorld::touchUpOutsideAction(CCObject *sender,CCControlEvent controlEvent)

{

    CCLabelTTF *m_pDisplayValueLabel=(CCLabelTTF*)this->getChildByTag(923);

    m_pDisplayValueLabel->setString(CCString::createWithFormat("外部抬起")->getCString());

}


广东省低应变题库 11.按《建筑地基基础检测规范》DBJ/T15-60-2019的规定,采用低应变法对混凝土预制桩进行检测时,地基基础设计等级为甲级的桩基工程抽检桩数不应少于总桩数的30%,其余桩基工程抽检桩数不应少于总桩数的20%,且不得少于10根;16.按《建筑地基基础检测规范》DBJ/T15-60-2019的规定,当对某桩的桩身完整性判定为III类时,可认为该桩不满足验收条件,不用进一步确定该桩桩身缺陷对桩身结构承载力的影响程度。2.地基基础检测所用计量器具均应在检定(校准、验证)的有效期内,性能符合相关技术要求。 阅读详情

相关推荐

CS1237卡尔曼滤波实战:如何用24位ADC实现电子秤级精度?

本文详细介绍了如何利用CS1237 24位ADC芯片结合卡尔曼滤波算法实现电子秤级精度测量。通过解析CS1237硬件特性、卡尔曼滤波原理及STM32驱动优化,提供了一套完整的解决方案,包括多通道支持、驱动代码实现和性能调优技巧,适用于工业测量和嵌入式开发领域。

linux的博客 1087

cccontrolbutton_cocos2dx基础篇(13)——按钮控件CCControlButton

【唠叨】按钮类CCControlButton继承于控件类CCControl。控件类CCControl主要向子类提供了一系列的控件触发事件。当子控件触发相关的事件后,就会执行相关的控件事件回调函数。这与之前讲的CCMenu中的菜单按钮回调是类似的。控件类CCControl主要有三个子类:(1)开关控件CCControlSwitch(2)滑块控件CCControlSlider(3)按钮控件CCCont...

weixin_34817716的博客 286

FusionCompute8.0.0实战指南:从零部署CNA与VRM环境

本文以华为FusionCompute 8.0.0为例,详细介绍了如何利用老旧硬件从零开始部署CNA计算节点与VRM管理节点的完整实战指南。内容涵盖实验环境准备、CNA安装与网络配置、VRM虚拟机部署方案对比,并提供了典型故障排查与性能调优技巧,帮助读者低成本构建可用的虚拟化学习环境。

weixin_29306317的博客 315

cccontrolbutton_CCControlButton 按钮

新建工程名为testButton。修改HelloWorldScene.h#ifndef __HELLOWORLD_SCENE_H__#define __HELLOWORLD_SCENE_H__#include"cocos2d.h"#include"cocos-ext.h"usingnamespacecocos2d::extension;class HelloWorld : public cocos...

weixin_39737001的博客 159

RimWorld Mod开发避坑指南:从Defs命名规范到XML结构详解(附实战代码)

本文深入解析RimWorld Mod开发中Defs文件的编写规范与高级技巧,涵盖命名冲突预防、XML结构优化及高级功能实现。通过实战代码示例,帮助开发者避开常见陷阱,提升Mod兼容性与稳定性,特别适合RimWorld Mod开发者参考。

weixin_30790841的博客 450

JSON(详解)

JSON(JavaScript Object Notation)是一种轻量级的数据交换格式。它以易于阅读和编写的文本格式来存储和表示数据,通常用于在不同的系统之间进行数据交换。JSON数据以键-值对的形式组织,可以包含对象、数组、字符串、数字等基本数据类型。它经常在Web开发、API通信等领域被广泛使用。

7704

cocos2dx基础篇(13)——按钮控件CCControlButton

【唠叨】 按钮类CCControlButton继承于控件类CCControl。 控件类CCControl主要向子类提供了一系列的控件触发事件。当子控件触发相关的事件后,就会执行相关的控件事件回调函数。这与之前讲的CCMenu中的菜单按钮回调是类似的。 控件类CCControl主要有三个子类: (1)开关控件CCControlSwitch ...

weixin_33858249的博客 322

RSA 2048/4096 签名校验算法

RSA算法是一种非对称密码算法,所谓非对称,就是指该算法需要一对密钥,使用其中一个加密,则需要用另一个才能解密。 RSA是目前最有影响力和最常用的公钥加密算法,它能够抵抗到目前为止已知的绝大多数密码攻击,已被ISO推荐为公钥数据加密标准。 今天只有短的RSA钥匙才可能被强力方式解破。到2008年为止,世界上还没有任何可靠的攻击RSA算法的方式。只要其钥匙的长度足够长,用RSA加密的信息实际上是不能...

qq_38769551的博客 9497

cccontrolbutton_cocos2dx的CCControlButton事件

(基于cocos2dx2.2.2)cocos2dx的按钮类定义在extensions\GUI\CCControlExtension\CCControlButton.h在需要用的时候,包括就可以了。我们在相应的申明的地方,包含下面三个头文件#include"GUI/CCControlExtension/CCControlButton.h"#include"GUI/CCControlExtensi...

weixin_42217306的博客 171

手把手教你用RV1103+SC3336摄像头DIY一个离线人脸门禁原型

本文详细介绍了如何利用RV1103芯片和SC3336摄像头构建离线人脸门禁系统。从硬件选型到算法优化,再到业务逻辑实现,提供了完整的DIY指南。重点讲解了RetinaFace和FaceNet算法在嵌入式系统中的移植与调优,帮助开发者快速实现高效、隐私安全的门禁解决方案。

weixin_26905487的博客 509

【DaVinci Configurator专题】-2-将CAN 2.0或CANFD Matrix的Arxml/DBC文件导入到CFG

共9页 目录 1 打开DaVinci Configurator,导入Arxml文件 2 解决导入Arxml文件后可能会出现的一些错误 3 验证CFG的配置 4 根据CFG的配置生成代码 5 结尾 <--返回「实战篇」博文-总目录--> <--返回「Autosar从入门到精通-实战篇」专栏主页--> 关键词: Open the Input Files Assistant Complete update process Update ECU configurati

「汽车电子助手」的博客 6125

CCEditBox实现原理

今天使用了EditBox,记录下几点重要的,可以说是CCEditBox实现原理 1.CCEditBox继承CCControlButton, CCIMEDelegate 2. CCEditBox实现了touchDownAction方法 ,并在 CCEditBox::initWithSizeAndBackgroundSprite方法中 调用了 this->addTargetWit

我爱1和0 个人主页:521100.net 715

当AI写小说——一个被严重低估的工程化战场

摘要 AI小说创作远非简单的prompt生成,而是一项需要系统化工程管理的复杂任务。本文通过真实案例分析,揭示了当前AI写小说存在的五大核心难题:设定一致性难以维持、文风控制缺乏个性、爽感节奏难以把握、长篇记忆能力有限以及平台规则适配困难。研究显示,90%的失败案例源于错误的创作方法,主要表现为对话框式随机生成和模板式同质化创作。要实现高质量的AI小说创作,必须建立包括设定治理、记忆管理、文风校准等在内的全链路工程化体系,而非依赖单一prompt指令。只有采用系统化的人机协同方法,才能突破当前AI创作的质量

sellyogurt的博客 682

CCControlButton 按钮

CCControlButton按钮也是cocos2d-x扩展的一个组件,还是应用程序中最常见、使用效率最高的组件 HelloWorld.h文件 #ifndef __HELLOWORLD_SCENE_H__ #define __HELLOWORLD_SCENE_H__ #include "cocos2d.h" #include "cocos-ext.h" #include "SimpleAud

幻影紫歆 670

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

cccontrolbutton_Cocos2dx使用CCControlButton创建按钮、按钮点击事件

#include "HelloWorldScene.h"#include "cocos-ext.h" //使用按钮事件,必须要需要的头文件USING_NS_CC;USING_NS_CC_EXT;//使用按钮事件,必须要需要的命名空间int hits=0;//全局变量,用来统计点击被点击次数CCScene* HelloWorld::scene(){// 'scene' is an autorelea...

weixin_36457572的博客 344

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

10 cocos2d-x 按钮 CCControlButton

#ifndef __HELLOWORLD_SCENE_H__ #define __HELLOWORLD_SCENE_H__ #include "cocos2d.h" #include "cocos-ext.h" using namespace cocos2d::extension; class HelloWorld : public cocos2d::CCLayer { public:

林彬的专栏 1028

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

cocos2dx基础篇(10) 按钮控件CCControlButton

【3.x】 (1)去掉“CC” (2)对象类CCObject改为Ref (3)按钮事件回调依旧为cccontrol_selector,没有使用 CC_CALLBACK_2 (4)按钮状态CCControlState改为强枚举Control::State // NORMAL //正常 HI...

diaosong8043的博客 337

cccontrolbutton_cocos2dx基础篇(10) 按钮控件CCControlButton

【3.x】(1)去掉“CC”(2)对象类CCObject改为Ref(3)按钮事件回调依旧为cccontrol_selector,没有使用 CC_CALLBACK_2(4)按钮状态CCControlState改为强枚举Control::State//NORMAL //正常HIGH_LIGHTED //高亮(即在内部触摸状态下)DISABLED ...

weixin_42308697的博客 246

cocos2dx基础篇(9)——按钮控件CCControlButton

【唠叨】     按钮类CCControlButton继承于控件类CCControl。     控件类CCControl主要向子类提供了一系列的控件触发事件。当子控件触发相关的事件后,就会执行相关的控件事件回调函数。这与之前讲的CCMenu中的菜单按钮回调是类似的。     控件类CCControl主要有三个子类:         (1)开关控件CCControlSwitch      ...

携墨的博客 732

Cocos2d-x 3.x基础学习: 按钮控件CCControlButton

按钮类CCControlButton继承于控件类CCControl,控件类CCControl主要向子类提供了一系列的控件触发事件。当子控件触发相关的事件后,就会执行相关的控件事件回调函数。这与之前讲的CCMenu中的菜单按钮回调是类似的。 控件类CCControl主要有三个子类: (1)开关控件CCControlSwitch (2)滑块控件CCControlSlider (3)按钮控件CCControlButton 本节讲的是其子类其中之一:按钮类CCControlButton。 Cocos2d

翻肚鱼儿的博客 589

cocos2d-x 3.3 按钮添加和事件(CCControlButton)

#include #include "ui/UIScale9Sprite.h" #include "GUI/CCControlExtension/CCControlButton.h" #include "GUI/CCControlExtension/CCControl.h" USING_NS_CC; USING_NS_CC_EXT; using ui::Scale9Sprite;

windvally的专栏 1945

cocos2dx----按钮控件CCControlButton

【唠叨】     按钮类CCControlButton继承于控件类CCControl。     控件类CCControl主要向子类提供了一系列的控件触发事件。当子控件触发相关的事件后,就会执行相关的控件事件回调函数。这与之前讲的CCMenu中的菜单按钮回调是类似的。     控件类CCControl主要有三个子类:         (1)开关控件CCControlSwi

wozhengtao的博客 1404

cocos2d-x CCControlButton,九妹图用按钮

bool bRet = false; do { //这样写比较保险: CC_BREAK_IF(!CCLayer::init()); //正常状态下的按钮图片; CCScale9Sprite * btnNormal = CCScale9Sprite::create("scale9.png"); //单击状态下的图片; CCScale9Sprite * btnDown =

SharlNagu的专栏 1634

cocos2dx CCControlButton 按钮事件

bool HelloWorld::init() {     //////////////////////////////     // 1. super init first     if ( !CCLayer::init() )     {         return false;     }     CCLabelTTF * label = CCLabelTTF::creat

navno1的专栏 623

cocos2d-x按钮CCControlButton的用法

转载请注明,原文地址:  http://blog.youkuaiyun.com/musicvs/article/details/8242963 1. 按钮创建 [cpp] view plaincopy /* 正常状态下的按钮图片 */       CCScale9Sprite* btnNormal = CCScale9

愤怒的小小强 1250

cocos2dx[2.x](8)--按钮控件CCControlButton

【唠叨】 按钮类CCControlButton继承于控件类CCControl。 控件类CCControl主要向子类提供了一系列的控件触发事件。当子控件触发相关的事件后,就会执行相关的控件事件回调函数。这与之前讲的CCMenu中的菜单按钮回调是类似的。 控件类CCControl主要有三个子类: (1)开关控件CCControlSwitch (2)滑块控件CCControl...

qq_34240791的博客 232
上一篇: CCControlSlider 滑动条
下一篇: 高清与非高清
缥缈的云
博客等级 码龄15年 94粉丝 179原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值