Some simple problems when use sprite

Hi,

Im porting my game from andengine to cocos2dx. And i have some problems.

1 - Position x = 0 and y = 0

When i set sprite position to “0, 0”, instead of it be on TOP and LEFT of screen, it goes to BOTTOM and LEFT. Look the image:
http://www.prsolucoes.com/downloads/error-cocos-1.png

I think that i any reference position to configure. Any idea?

2 - Cant change position or move a sprite

When try change sprite position after add as child of scene, the same problem i get when use an action to move player, get some errors, look the image:

http://www.prsolucoes.com/downloads/error-cocos-2.png

My code to do it:

layerPlayers~~>addChild);
GameObjects::player~~>getSprite()>setPosition);
>
cocos2d::CCMoveTo *moveAction = cocos2d::CCMoveTo::actionWithDuration);
GameObjects::player
>getSprite()->runAction(moveAction);

The strange problem is that i dont get this error always that i execute. Have some times that it start and other times it doesnt happen. But on most time i got the error. I think that can be a concurrency problem or something like this, or something that is updating the sprite, i dont know. Any idea?

Thanks

  1. Cocos2d coordinate system is the same to OpenGL, but different from common UI systems. The bottom-left corner is (0,0), x & y values increase if you go to top-right. One of my friend modified the framework to fit the coordinate system as you said in 2010, he had a nightmare and finally told me, he won’t change the coordinate any more.

  2. Your code looks correct. I think it depends on other code relative to this sprite.