Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to run an action on a sprite using the MoveBy action. After lots of attempts, I can't achieve the goal... I have issues with the MoveBy in 2 different projects, so maybe I'm missing something in the setup... But I can't figure what!

The instruction is like this:

this.platform1Sprite.runAction(cc.MoveBy.create(1, cc.p(200, 0)));

I don't get any error, simply it doesn't work. platform1Sprite is a Sprite. But even with a LabelTTF it doesn't work:

var MoveToAction = cc.MoveTo.create(2.5, cc.p(size.width / 2, size.height / 2));

For this last snippet, you can view my complete code here:

The code I linked is somehow similar to the helloHTML5World official example, line 112 has the runAction method applied to a LabelTTF. The official example works, mine doesn't... I can't understand what's the difference!

share|improve this question
The code works for me. Is platform1Sprite a cc.Sprite? – eazimmerman Oct 16 '12 at 14:25
Yes, it is. In the official COCOS2D-x forum they also said the code works. But I'm sure it doesn't! In the link to the forum there's the full code of a project that doesn't work. I'm using FF16, but even with Chrome it doesn't work (in 2 different computers). Suggestions? – ufo Oct 16 '12 at 14:30
If you put your code into and link me, I will be glad to look it over for you. – eazimmerman Oct 16 '12 at 14:40 Lines 17 and 18 have the MoveTo action! – ufo Oct 16 '12 at 21:02
are you sure you are not disabling schedule manager somewhere by mistake? – Ali.S Oct 18 '12 at 9:08
up vote 2 down vote accepted

I found out the problem! :)

In "credits.js" you need to change:

onEnter:function() {    

onExit: function() {


onEnter:function() {

onExit: function() {

Hope this works for you!

The reason actions were not running is because 1) the engine was not being notified of any of the objects in the layer and 2) the scheduler/actions were not being resumed for said layer.

CCNode.js's onEnter( ), called through CCLayer.js's onEnter( ):

onEnter:function () {
    this._isRunning = true;//should be running before resumeSchedule
    this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onEnter);
share|improve this answer
Thank you... Unfortunately your solution seems wrong. Either the first snippet and the one after the EDIT don't work... Anyway, if you look at the HelloHTM5World official example there's nothing similar to what you posted... And that example works! Look at line 112 for LabelTTF's runAction method. Thank you very much for your help! – ufo Oct 18 '12 at 6:59
I zipped the code I used here: It was built from your pastebin code and it works in firefox and chrome. – eazimmerman Oct 18 '12 at 20:42
Also, if you delete the onEnter and onExit functions the code works. That's how the official example is coded; without the functions. – eazimmerman Oct 18 '12 at 21:03
Yes, you're right. The pastebin code referred to a slight different project. And without the onEnter and onExit methods (or using the super definition) it works. But the original project, that's here, didn't work with the line 167 uncommented... What if I want to schedule update??? I can't figure why it doesn't work! Thank you very much! – ufo Oct 22 '12 at 6:59
to schedule an update: in your init add "this.schedule(this.update);" then have a function like: "update:function (delta){}," – eazimmerman Oct 30 '12 at 13:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.