Cc.SpriteBatchNode child positioning bug while render mode is WebGL

Hi,

I’ve run into kind of a roadblock while trying to move a sprite. Sounds too silly but my sprite has been added to a batch node. And all I’m doing is reducing the x-position at every tick.

If I add this sprite to a cc.Layer, it moves just fine. But if I add it to a cc.SpriteBatchNode, it won’t move.

Also, if I set renderMode to Default/WebGL, the sprite doesn’t move. But if I set renderMode to Canvas, it works fine.

Any help would be greatly appreciated.

I’m using:
cocos2d-html5 ver.2.2.3
Chrome: 36.0.1985.125
Firefox: 31.0

Hi

Can you show us some code snippets?
I have tested it with cc.MoveBy action on a sprite within a cc.SpriteBatchNode and it works just fine.

HelloHTML5World.zip (865.6 KB)

Hey,

Thanks in abundance for the quick response. I have attached a project to this post. The renderMode has been left as “0”.

I ran this on the following browsers on my Windows machine:
Chrome: 36.0.1985.125
Firefox: 31.0

Please change the renderMode to “1” and you will notice that setPositionX() works just fine for Canvas rendering but not for WebGL.

Please do let me know if this is an issue with the browser or with the engine or if there is something wrong that I’m doing.

Thanks again.

This is a bug of cc.Sprite, I have fixed it in this pull request:

You can merge my pr or modify you code like this, it will also work:

update:function() {
    for(var i = 0; i < MAX_SPRITES; ++i)
    {
        var sprite = this.sprites[i];
        sprite.setPosition(sprite.getPositionX() - 1, sprite.getPositionY());
    }
}

Thanks a lot :smiley: