0

I'm very confused with a weird behaviour in Cocos2d-x, when I create a CCSprite and a CCMenu with a single CCMenuItem, even thought all of them are positioned at the same location.

mySprite->setPosition(ccp(0,0));
myMenu->setPosition(ccp(0,0));

mySprite is at one place and myMenu with its myMenuItem are at another location, what is happening? and how can I fix this?

Thanks! :'D

mtet88
  • 524
  • 6
  • 21

3 Answers3

0

In a CCMenu you are not supposed to manually change the position of the items (and their children). Only change the position of the menu itself.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
0

I found the answer, I was using setScale on CCMenu, this messes up the position of every child, you have to use setScale on each CCMenuItem instead of the CCMenu.

mtet88
  • 524
  • 6
  • 21
0
Sprite->setPosition(ccp(100,100));
Menu->setPosition(ccp(100,100));