PDA

View Full Version : getting an object outside of scriptgroup


lakitu42
4th July 2002, 04:02
I had a thread before about running animations backwords. You just declare a timer. Set it's delay to the same as the animation and make it so ontimer sets the animation to the frame previous to it. Like this:

//always remember std.mi
#include <Lib\std.mi>

Global button rwbutton;
Global button playbutton;
Global timer animtimer;
Global animatedlayer anim;

system.onScriptLoaded()
{
Layout mainnormal = system.getContainer("Main").getLayout("normal");
rwbutton = mainnormal.getObject("rwind");
playbutton = mainnormal.getObject("playanim");
anim = mainonrmal.getObject("anim");
animtimer = new Timer;
animtimer.setDelay(100);
anim.setSpeed(100);
}

animtimer.onTimer()
{
anim.goToFrame(anim.getCurFrame() - 1);
}

rwbutton.onLeftClick()
{
if(anim.isPlaying())
anim.stop();
animtimer.start();
}

playbutton.onLeftClick()
{
animtimer.stop();
anim.play();
}

anim.onFrame(1)
{
animtimer.stop();
}

mp!
4th July 2002, 07:18
havent played with groups too much so im not sure but for the animation , instead of timers you could use :

extern AnimatedLayer.setStartFrame(Int framenum);
extern AnimatedLayer.setEndFrame(int framenum);


i used that to make an animation bounce back and forth between beginning and end. you can probably modify it to fit your needs.

#include </lib/std.mi>

Global AnimatedLayer animation;

System.onScriptLoaded()
{
Layout mainLayout = getContainer("main").getLayout("normal");
animation = mainLayout.getObject("ani.layer");
animation.setSpeed(100);
animation.setAutoReplay(true);
animation.play();
}

animation.onframe(Int framenum)
{
if (framenum == animation.getlength() - 1 && animation.getDirection() == 1) {
animation.setStartFrame(animation.getLength() - 1);
animation.setEndFrame(0);
}

else if (framenum == 0 && animation.getDirection() == -1)
{
animation.setStartFrame(0);
animation.setEndFrame(animation.getLength() - 1);
}
}