简体   繁体   English

在Cocos2dx中同时运行许多效果操作

[英]Run many effect actions simultaneously in Cocos2dx

I'm new to Cocos2dx and I'm trying to create a planet animation rotate itself by using a 3:1 rectangle texture, which contains 3 squares are two faces (map) of sphere (the third square is a clone of the first one). 我是Cocos2dx的新手,我正在尝试通过使用3:1矩形纹理创建一个行星动画旋转,其中包含3个正方形是球体的两个面(地图)(第三个正方形是第一个的克隆) )。 I create a frames array by cropping the texture and add them to CCAnimation. 我通过裁剪纹理创建一个帧数组并将它们添加到CCAnimation。 Then I test this animation with two effects to make square frame become a 3D circle: CCLens and CCTurnOffTiles (I will modify it in the future to turn off only grids outside the circle). 然后我用两个效果测试这个动画,使方框成为一个3D圆圈:CCLens和CCTurnOffTiles(我将来修改它只关闭圆圈外的网格)。

But there is a problems: two effects don't stack. 但是有一个问题:两个效果不叠加。 If CCTurnOffTiles is added after CCLens, CCLens will not work; 如果在CCLens之后添加CCTurnOffTiles,CCLens将无法工作; if CCLens is added after CCTurnOffTiles, CCDirector will throw reading violation exception at runtime. 如果在CCTurnOffTiles之后添加CCLens,CCDirector将在运行时抛出读取违例异常。

Is there any solution to run many effects simultaneously or implement planet animation in other way? 是否有任何解决方案可以同时运行多种效果或以其他方式实现行星动画? Thanks. 谢谢。

Try using CCSpawn . 尝试使用CCSpawn

// Create the effects
CCLens3D * lensEffect; // Your CCLens3D create()
CCTurnOffTiles * turnOff; // Your CCTurnOfftiles create()

// Create a spawn to run them simultaneously
CCSpawn * sphereEffect = CCSpawn::createWithTwoActions( lensEffect, turnOff );

// Run the spawn
myObject -> runAction( sphereEffect );

Both CCTurnOffTiles and CCLens3D inherits of CCGridAction. CCTurnOffTiles和CCLens3D都继承了CCGridAction。

But one cancels the other: CCTurnOffTiles will turn off grid tiles, and CCLens3d need these grid tiles. 但是一个取消另一个:CCTurnOffTiles将关闭网格图块,CCLens3d需要这些网格图块。

I recommend you to draw all planet sprites, already circled and using a SpriteSheet, and animate then with CCAnimation, without using CCTurnOffTiles or CCLens3D. 我建议你绘制所有行星精灵,已经盘旋并使用SpriteSheet,然后使用CCAnimation制作动画,而不使用CCTurnOffTiles或CCLens3D。 It is easiest and will consume less cpu. 这是最简单的,将消耗更少的CPU。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM