Hi,
I have a simple [RepeatForever ..] action that uses an animation to simulate a character walking.
runAnim = [[AtlasAnimation animationWithName:@"run" delay:0.2f] retain];
for(int i = 0; i < 6; i++) {
[runAnim addFrameWithRect:CGRectMake(i*100, 0, 100, 100)];
}
id runAction = [RepeatForever actionWithAction:[Animate actionWithAnimation:runAnim]];
[sprite runAction:runAction];
This is fine, but what I wish to do is dynamically change the delay of the animation.
for example, I want the animation to be quicker the more tilted the phone is, so it looks like the character is running faster.
I thought this would do it..
[runAnim setDelay:tiltX]; // float - tiltX is the accelerometer data
But this doesnt actually do anything, I am thinking its because the action is already defined with the animation at a 0.2f delay.
Any suggestions?
P.S I have actually made a working hack version by manually adjusting the sprites texture rect depending on the value of the accelerometer, but this is ugly and very dependant on the scheduler tick.