How can I start my object animation from the same frame where I stopped it? For example, let's say I have an animated spinning wheel that loops repeatedly with NoBlock on. When I click it, it stops instantly in it's current frame. This is great. Now when I click it again using the "Animate"-command, it jumps to the first frame of the loop, which is bad. I want it to continue from the same frame where it stopped.
Plan B would be to wait that the loop is finished and stop it then, but it's not what I'm really looking for. I want the actions to be instantaneous.
Couldn't find any answer for this, so any help is welome!
How many Frames are there?
Something possibly like this:
After you stop the wheel you could do a Frame check and set it as SetView.
}
if(!wheel.Animting) // when you have stopped the wheel
if(Frame==0){
oWheel SetView(6,0,0)// Will show oWheel View 6 Loop 0 Frame 0. oWheel being what your object name or ID}
}
else if(Frame==1){
oWheel SetView(6,0,1)// Will show oWheel View 6 Loop 0 Frame 1. oWheel being wjat your object name or ID}
// etc etc
}
}
Afaik this isn't possible using the Animate() or some other command; you have to manually change the object's sprite.
Say the wheel sprites are in slots 134 to 145.
int delay = 3; // animation delay
bool spinning;
int frame = 0, frame_delay = 0;
function room_RepExec() {
if (spinning) {
frame_delay = (frame_delay + 1) % delay;
if (frame_delay == 0) {
frame = (frame + 1) % 12; // 12 frames
oWheel.Graphic = frame + 134;
}
}
}
Now you can start/stop the wheel by setting spinning to [/i]true/false[/i].
Thanks Slasher & Khris for the quick answers!
Yes, I was afraid that I cant use the animate-command. I have 25 frames so custom manipulation with the views seems complicated. But I did a quick test with the script and it seems to work fine, so I'll use it for now and report back if there is trouble. Thanks Khris!
Solved! ;-D
You can use the StopAnimating();command and check from there.
But as you say, you have quite a few frames.
Khris' solution is neat and a lot less work (nod)