cocos2dx3.2新手教程2-----飞机大战
来源:互联网 发布:淘宝怎么引自然流量 编辑:程序博客网 时间:2024/04/28 14:09
上一章讲到了模拟飞机的飞行,这章主要讲我们的主角-----飞机的添加和控制移动
1.首先创建一个飞机
player=Sprite::create("player.png");
player->setPosition(Vec2(visiableSize.width/2,player->getContentSize().height/2));
addChild(player);
.h中需要声明player精灵
然后添加触摸方法,在3.2中的触摸方法是这样的
//触摸方法
auto listener=EventListenerTouchOneByOne::create();
listener->onTouchBegan=CC_CALLBACK_2(HelloWorld::onTouchBegan,this);
listener->onTouchMoved=CC_CALLBACK_2(HelloWorld::onTouchMoved,this);
listener->onTouchEnded=CC_CALLBACK_2(HelloWorld::onTouchEnded,this);
Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener,player);
在.h中声明
//触摸飞机
virtual bool onTouchBegan(Touch *touch, Event *event);
virtual void onTouchMoved(Touch *touch, Event *event);
virtual void onTouchEnded(Touch *touch, Event *event);
然后就是实现
最后就是实现的画面了(这里我对飞机的范围限制没有写,大家自己可以写一下)
- cocos2dx3.2新手教程2-----飞机大战
- cocos2dx3.2新手实战教程-----飞机大战之路
- 飞机大战-2
- 飞机大战2
- 飞机大战制作笔记2
- Python开发飞机大战(2)
- cocos2dx飞机大战教程Cocos2d-x飞机大战运行效果
- Cocos2d-x飞机大战教程笔记
- unity飞机大战(2)一些细节问题
- 微信飞机大战--基于cocos2d-x3.2
- pygame编写飞机大战(2)-pygame快速入门
- 飞机大战
- 飞机大战
- 飞机大战
- 飞机大战
- 飞机大战
- 飞机大战
- 飞机大战
- 获取中英数组合个数
- CocoaPods安装和使用教程
- android开发步步为营之34:四大组件之ContentProvider
- CTL_CODE说明
- How to create a bootable USB stick on OS X
- cocos2dx3.2新手教程2-----飞机大战
- openstack中horizon学习
- interceptor拦截器
- HDU 5038
- iOS 之自定义URL Scheme完全指南
- Cannot mix incompatible Qt library (version ) with this library (version )
- IDispatch接口 - 跨语言调用
- gdb中忽略信号处理 SIGPIPE
- [贪心] hdu 4415 Assassin’s Creed