当前位置:网站首页>Method of cocos2d-x sprite moving
Method of cocos2d-x sprite moving
2022-07-29 09:57:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack , I wish every programmer can learn more languages .
1. The plane fired bullets
Want to achieve the flight effect of bullets , I don't want to be in every frame Update Calculation position in , The best method call CCMoveTo
For example, when the bullet is fired , can ccTouchBegan when :
CCMoveTo* move = CCMoveTo::create(0.4f, ccp(_plane->getPosition().x+winSize.width/4, _plane->getPosition().y));// The range is screen 1/4, The starting point is the position of the aircraft , use 0.4 Seconds to complete the range
_bullet->runAction(CCSequence::create(move, CCCallFuncN::create(this, callfuncN_selector(BaseLayer::bulletRemove)), NULL)); // Remember to destroy the bullets after flying The way to destroy bullets project And decide , This is my own project How to write it :
void BaseLayer::bulletRemove(CCNode* spend)
{
CCSprite* sprite = (CCSprite*)spend;// Pass it on CCNode Convert to bullets
// Destroy the bullets from the array
_bulletArray->removeObject(sprite, true);
_batchNode->removeChild(sprite, true); // Really destroy bullets from batch processing nodes
}Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/118860.html Link to the original text :https://javaforall.cn
边栏推荐
- Div horizontal layout aligned on both sides
- Examples of specific usage of diagnostic instructions in s7-1200 and s7-1500 (led+devicestates+modulestates)
- QoS服务质量五QoS边界行为之流量整形
- Unity3d empty package APK error summary
- Implementation and verification logic of complex expression input component
- A little knowledge ~ miscellaneous notes on topics ~ a polymorphic problem
- 怎么样的框架对于开发者是友好的?
- 还是有机会的
- Excel tool for generating database table structure
- [苹果开发者账号]06 转让开发者账号后,开发者年费自动续费问题
猜你喜欢

程序员脱离单身的一些建议

Why does the system we developed have concurrent bugs? What is the root cause of concurrent bugs?
![[C language] Sanzi chess (intelligent chess playing + blocking players)](/img/36/4a269887189e64562227a8592433c3.png)
[C language] Sanzi chess (intelligent chess playing + blocking players)

How can Plato obtain premium income through elephant swap in a bear market?

Gao Zhiwei: data management enables the digital transformation of the transportation industry

Yin Yi: my learning and growth path

Anfulai embedded weekly report no. 273: 2022.07.04--2022.07.10

Basic operations of OpenCV image processing

Webassembly 2022 questionnaire results are fresh

英特尔联合Datawhale,发布学习项目!
随机推荐
Unity guidance system. Click the target object and prompt the text to change color to enter the next step
Node (II)
i. Mx6ull driver development | 32 - manually write a virtual network card device
Unity3d hodgepodge
[AAAI] attention based spatiotemporal graph convolution network for traffic flow prediction
Explanation of C value type and reference type
Why does the system we developed have concurrent bugs? What is the root cause of concurrent bugs?
深入浅出依赖注入及其在抖音直播中的应用
Sed, regular expression of shell programming
Harmonyos 3.0 release!
怎么样的框架对于开发者是友好的?
Gao Zhiwei: data management enables the digital transformation of the transportation industry
Problems and solutions of introducing redis cache
Source code analysis of senparc.weixin.sample.mp
shell编程之sed,正则表达式
PyQt5快速开发与实战 6.1 好软件的三个维度 && 6.2 PyQt5中的布局管理 && 6.3 PyQt5的绝对位置布局
机器学习之逻辑回归(Logistics Regression)
Nucleic acid scanning code registration experience (how to improve the correct character recognition rate of OCR)
Vector implementation
Div horizontal layout aligned on both sides