I'm using cocos2d and I create a CCDrawNode
.
The moment I call addChild:
to add the CCDrawNode
I call the following method to make the node scale forever:
CCActionScaleBy *scaleAction = [CCActionScaleBy actionWithDuration:0.3f scale:1.1f];
CCActionRepeatForever *repeatForever = [CCActionRepeatForever actionWithAction:scaleAction];
[self runAction:repeatForever];
Unfortunately when trying to access the CCDrawNode
boundingBox
it's width and height don't change with scale action.
What causes that and how can I get it's real width and height?
Thanks!
A quick look into the implementation of CCActionScaleBy shows that it plays around with the scale
property of the node while not tampering the contentSizeInPoints
property. The boundingBox
is the rect obtained using 0,0 as origin and contentSizeInPoints
property for width and height dimensions.
An easy way to obtain the actual width and height would be to multiply contentSize/boundingBox.size
with the current scale value:
CGFloat actualWidth = self.boundingBox.size.width * self.scale;
CGFloat actualHeight = self.boundingBox.size.height * self.scale;