4

I have a trouble trying to make one circle big and small using [SKAction scaleBy: duration:]

SKAction *scaleDown = [SKAction scaleBy:0.2 duration:1.8];  
SKAction *scaleUp= [scaleDown reversedAction];
SKAction *fullScale = [SKAction sequence:@[scaleDown, scaleUp, scaleDown, scaleUp]];
[_circleChanging runAction:fullScale];

What I get is the circle becoming so small that disappears and then doesn't come back. It has to become small and then come back to his original size doing it 2 times.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Alex Delgado
  • 984
  • 11
  • 19
  • So what you're saying is that the circle continues to scale down until you can't see it any more, rather than stopping at a scale factor of 0.2, and scaling back up to its original size? – Smikey Dec 03 '13 at 16:17

2 Answers2

3

Try:

  SKAction *scaleDown = [SKAction scaleTo:0.2 duration:0.75];
       SKAction *scaleUp= [SKAction scaleTo:1.0 duration:0.75];
       SKAction *fullScale = [SKAction repeatActionForever:[SKAction sequence:@[scaleDown, scaleUp, scaleDown, scaleUp]]];
       [_circleChanging runAction:fullScale];
Smikey
  • 8,106
  • 3
  • 46
  • 74
  • Thanks. It should have been obvious, but I was locked into believing `reversedAction` would actually do what I wanted. – Echelon Sep 06 '14 at 12:04
2

Not all actions are reversible, and the reverse sometimes doesn't mean "go back to the original value".

If you check the documentation, the reverse action of scaleBy is actually scaling to -0.2 in your case. Just create a new scale action instead of reversing.

Also try making a copy of the actions for the 2nd use:

SKAction *fullScale = [SKAction sequence:
                       @[scaleDown, scaleUp, [scaleDown copy], [scaleUp copy]]];
CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • ok, I have changed: SKAction *scaleUp= [scaleDown reversedAction]; By: SKAction *scaleUp= [SKAction scaleBy:3.0 duration:1.8]; and I still have the same main problem, the circle becomes as small that disappears. – Alex Delgado Dec 03 '13 at 16:09
  • check my update, perhaps this has to do with using the same actions multiple times in the sequence where they might need to be copies (more a guess than anything) – CodeSmile Dec 03 '13 at 16:53