Cocos2d sprite's parent not reflecting true scale value
Posted
by
Paul Renton
on Game Development
See other posts from Game Development
or by Paul Renton
Published on 2013-06-30T23:09:46Z
Indexed on
2013/07/01
4:29 UTC
Read the original article
Hit count: 351
cocos2d
|objective-c
I am encountering issues with determining a CCSprite's parent node's scale value.
In my game I have a class that extends CCLayer and scales itself based on game triggers. Certain child sprites of this CCLayer have mathematical calculations that become inaccurate once I scale the parent CCLayer. For instance, I have a tank sprite that needs to determine its firing point within the parent node.
Whenever I scale the layer and ask the layer for its scale values, they are accurate. However, when I poll the sprites contained within the layer for their parent's scale values, they always appear as one.
// From within the sprite
CCLOG(@"ChildSprite-> Parent's scale values are scaleX: %f, scaleY: %f",
self.parent.scaleX, self.parent.scaleY); // Outputs 1.0,1.0
// From within the layer
CCLOG(@"Layer-> ScaleX : %f, ScaleY: %f , SCALE: %f",
self.scaleX, self.scaleY, self.scale); // Output is 0.80,0.80
Could anyone explain to me why this is the case? I don't understand why these values are different. Maybe I don't understand the inner design of Cocos2d fully. Any help is appreciated.
© Game Development or respective owner