about setPosition(float x, float y)

about setPosition(float x, float y)
0.0 0


It seems like I can’t use the setPosition(float x, float y) in lua, but I could see it in CCNode.pkg, why ?


I use it all the time it works fine.

aNode = CCMenu:create()
aNode:addChild(im) — im is a CCMenuItemImage
aNode:setPosition(hw * (c 1) - hw/2, wSize.height - hw * hw/2)

make sure x and y are number

try aNode:setPosition(tonumber(x), tonumber(y)) — just in case

wrong type is an easy mistake in Lua

Good luck



Thank you, let me have a try :slight_smile:


Note that if you have a CCSprite it may not work CCSprite only reimplement SetPosition with a CCPoint and this is likely an error.



Yes, what I said is just CCSprite.


Ok if you use CCSprite then only CCPoint is valid and this is an error.

But you cannot use it because it is not defined in the package.

You could cast your sprite to CCNode using tolua.cast(sprite, ‘CCNode’).

Sorry my earlier comments where wrong.

Good luck.