0

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!

jkigel
  • 1,592
  • 6
  • 28
  • 49

1 Answers1

0

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;
Abhineet Prasad
  • 1,271
  • 2
  • 11
  • 14
  • Hiya,this may well answer the question... but don't forget there are total n00bs that will come to the question and wonder how this solves the problem... it's always a good idea to add some content that explains why your solution worked. :) – Taryn East Mar 25 '14 at 23:46