@rraallvv wrote:
I’m using the following snippet to create an animation in a blank project created with Cocos using the precompiled version of Cocos2d-x v3.10, both for C++ and Lua.
C++
// Animation test auto visibleSize = Director::getInstance()->getVisibleSize(); auto pterodactyl = Sprite::create("frame1.png"); pterodactyl->setPosition(visibleSize.width / 2, visibleSize.height / 2); auto animation = Animation::create(); int i, number; std::string name; for (i = 1; i <= 3; i++) { number = i; name = "frame" + std::to_string(number) + ".png"; animation->addSpriteFrameWithFile(name); } animation->setDelayPerUnit(0.5 / 3.0); animation->setRestoreOriginalFrame(true); animation->setLoops(-1); auto animate = Animate::create(animation); pterodactyl->runAction( animate ); auto moveOut = MoveTo::create(0, Vec2(visibleSize.width + 100, visibleSize.height * 0.8)); auto moveIn = MoveTo::create(4.0, Vec2(-100, visibleSize.height * 0.8)); auto delay = DelayTime::create(2.5); pterodactyl->runAction(RepeatForever::create(Sequence::create(moveOut, moveIn, delay, NULL) ) ); addChild(pterodactyl);
Lua
--Animation test local pterodactyl = cc.Sprite:create("frame1.png") pterodactyl:setPosition(display.cx, display.cy) local animation = cc.Animation:create() local number, name for i = 1, 3 do number = i name = "frame"..number..".png" animation:addSpriteFrameWithFile(name) end animation:setDelayPerUnit(0.5 / 3.0) animation:setRestoreOriginalFrame(true) animation:setLoops(-1) local animate = cc.Animate:create(animation) pterodactyl:runAction( animate ) -- <-- this is not working on iOS devices local moveOut = cc.MoveTo:create(0, cc.p(visibleSize.width + 100, visibleSize.height * 0.8)) local moveIn = cc.MoveTo:create(4.0, cc.p(-100, visibleSize.height * 0.8)) local delay = cc.DelayTime:create(2.5) pterodactyl:runAction(cc.RepeatForever:create(cc.Sequence:create(moveOut, moveIn, delay) ) ) self:addChild(pterodactyl)
The problem is that the animation won’t work on iOS devices when cerated with Lua. The sprite looks the same as if the method runAction was not executed.
I tested OS X for both C++ and Lua, and it works ok, also the iOS simulator seems to run the action. On iOS devices (iPod Touch 4g and iPad mini) only C++ seems to work.
Posts: 1
Participants: 1