当前位置:网站首页>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
边栏推荐
- 还是有机会的
- Some suggestions for programmers to leave single
- Pyqt5 rapid development and practice 6.5 qgridlayout (grid layout)
- Tips of Day1 practice in 2022cuda summer training camp
- 7.9-7.17 new features and grammar of learning plan ES6
- How to realize the isolation level between MySQL transactions and mvcc
- Which hero is the most difficult for lol in terms of code?
- English语法_不定代词 - 常用短语
- Pyqt5 rapid development and practice 6.1 three dimensions of good software & 6.2 layout management in pyqt5 & 6.3 absolute location layout of pyqt5
- Explanation of C value type and reference type
猜你喜欢

【C语言】扫雷(递归展开 + 标记功能)

Encyclopedia of introduction to machine learning - 2018 "machine learning beginners" official account article summary

English语法_不定代词 - 常用短语

Senparc.Weixin.Sample.MP源码剖析

这是一份不完整的数据竞赛年鉴!

The latest translated official pytorch easy introduction tutorial (pytorch version 1.0)

What kind of framework is friendly to developers?

Function - (C travel notes)

Examples of specific usage of diagnostic instructions in s7-1200 and s7-1500 (led+devicestates+modulestates)

Which hero is the most difficult for lol in terms of code?
随机推荐
数据可视化的利器-Seaborn简易入门
OpenCV入门基础学习
TCP failure model
Div horizontal arrangement
Yin Yi: my learning and growth path
Libyuv module
A sharp tool for data visualization Seaborn easy to get started
阿左的境界
Custom configuration
How can Plato obtain premium income through elephant swap in a bear market?
How to introduce your project experience?
网络安全(6)
Vector implementation
Senparc.Weixin.Sample.MP源码剖析
函数——(C游记)
[wechat applet] interface generates customized homepage QR code
【C语言】三子棋(智能下棋 + 阻拦玩家)
Four types of technical solutions shared by distributed sessions, and their advantages and disadvantages
Dynamics 365Online 如何自定义商机关闭窗体
Basic operations of OpenCV image processing