Button使用总结
来源:互联网 发布:数控车床g84攻牙编程 编辑:程序博客网 时间:2024/05/20 22:40
Button 的create函数可以传入三个资源图片参数,第一个是初始的状况,第二个是点击时候的图片(如果为NULL,默认为变大),第三个是设置为不可用(Enable设置为false)的图片(如果为NULL,默认为显示为灰色)
Button* button = Button::create("green_block.png"); button->setName("button"); button->setTitleText("1"); button->setPosition(Point(100, 100)); this->addChild(button); button->addClickEventListener(CC_CALLBACK_1(HelloWorld::Click,this));
void HelloWorld::Click(cocos2d::Ref * ref){ //Button* button = static_cast<Button *>(ref); //button->setEnabled(false); auto bird = static_cast<Sprite*>(getChildByName("bird")); bird->stopAllActions(); int x = random(-50, 50); int y = random(-50, 50); MoveBy* moveby = MoveBy::create(1.2, Vec2(x, y)); //int z = random(0, 3); if (x >= 0 && y < 0) { z = 0; } if (x < 0 && y < 0) { z = 1; } if (x >= 0 && y >= 0) { z = 2; } if (x < 0 && y >= 0) { z = 3; } Animation* animation = static_cast<Animation*>(anim_array->getObjectAtIndex(z)); Animate *animate = Animate::create(animation); Repeat* repeat = Repeat::create(animate,3); Spawn* spw = Spawn::create(moveby, repeat, NULL); CallFunc* call = CallFunc::create(this, callfunc_selector(HelloWorld::callback)); Sequence* sq = Sequence::create(spw, call, NULL); bird->runAction(sq);}
0 0
- Button控件使用总结
- Button使用总结
- Button的使用总结
- iOS关于Button使用的一些总结
- 活动中的 findViewById()方法总结以及Button按钮的使用
- iOS总结(自定义button)
- iOS button总结
- Radio button 使用方法总结
- Button基本功能总结!
- button与input button的使用
- radio button 简易使用
- Radio Button的使用
- asp:Button 使用背景图片
- Radio Button的使用
- Tkinter中的button使用
- Button 使用Reskey
- Button按钮的使用
- Radio Button的使用
- 反转单链表
- xcode报错 library not found for -lAFNetworking
- java内存分配分析/栈内存、堆内存
- 模板编程的文件组合方式
- Java中的堆和栈的区别
- Button使用总结
- js跨域
- Oracle Connect by 用法解析
- ARC下内存需要做的手动管理
- Software-Building-HOWTO_1
- mybatis中mapper.xml文件详解
- linux服务器校对时间方法
- 被坑的简单设计
- 修改默认闹铃为不振动