Forum > Lua Binding > the addChild of CCParallaxNode have one bug for lua

the addChild of CCParallaxNode have one bug for lua

By alexcheng Posted 2012-02-17 09:45 Comments 0
alexcheng
  • Posts: 15

1:bug:
CCParallaxNode:
@
virtual void addChild(CCNode * child, unsigned int z, const CCPoint& parallaxRatio, const CCPoint& positionOffset);
@
the param z is unsigned int.

for tulua++ in luacocos2d.cpp is :
@ cocos2d::CCParallaxNode* self = (cocos2d::CCParallaxNode**) tolua_tousertype;
cocos2d::CCNode** child = ((cocos2d::CCNode*) tolua_tousertype(tolua_S,2,0));
unsigned int zOrder = ((unsigned int) tolua_tonumber(tolua_S,3,0));
@
When “tolua_tonumber(tolua_S,3,0)” is a negative number and lua_number is double,z maybe isn’t same with the expected value.

when call CCNode::addChild in CCParallaxNode::addChild, z will convert to int, but it’s not same with the value writed in lua codes.

On windows and ios simulator,it work well.
but on Iphone device,it’not work.

So, the addChild of CCParallaxNode should be defined as below:
@
virtual void addChild(CCNode * child, int z, const CCPoint& parallaxRatio, const CCPoint& positionOffset);
@

2:Another suggestion:
In CCParallaxNode, the interface absolutePosition will be defined as a virtual and public method,because it maybe changed:
@
virtual CCPoint absolutePosition();
@

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps