Problem with animating object. (SOLVED)

Started by Hans, Fri 12/01/2007 23:21:09

Previous topic - Next topic

Hans

I have a problem. I want an object to change it's look, when I enter the room, but that causes some sort of error. The script is:

  // script for Room: Player enters room (before fadein)
object[0].SetView (7);
object[0].Animate(0,0);
object[0].StopAnimating();

What is wrong?

I was making a door, that is supposed to be closed every time I enter the room. Is there another way to do that, if this one is wrong?

Khris

First of all, this code should go into (after fadein). Otherwise you won't see the door animating because the room hasn't faded in yet.

"Some sort of error"!? Please post the exact error message...

I'm not sure about the default RepeatStyle; if the default is eRepeat, the script will never finish because by default Animate is blocking.
If the default repeat setting is eOnce, the call to StopAnimating is redundant.

So to be on the safe side, call object[0].Animate(0,0,eOnce); and remove object[0].StopAnimating();.
Btw, if you enter e.g. "DOOR" as the script o-name for the door, you can use oDoor.Animate(...);

Ashen

#2
If you just want it to BE closed when you enter the room, try Object.Graphic to set the object's graphic (or, set the defualt graphic as closed and leave it alone). if you want it to CLOSE when you enter the room (i.e. show the animation), then re-read the manual, especially the eBlock parameter bit. (As a general point, you might also want to try a higher delay than 0. I usually '3', but that's just me. And 'AFTER fadein' is probably best.)

Beyond that - as Khris said, 'some sort of error' isn't really much use - tell us WHAT error you get.
I know what you're thinking ... Don't think that.

Hans

#3
This has already helped me a lot. Thank you.
I know 'some sort of error' is not too specific, but I assumed that you could see, what's wrong in the code.
"After fadein" did it. Thanks again.

Hans

#4
I wan't the door to be closed when I enter the room.
So I now have (before fade in):

object[0].SetView(7,0,0)

Only that. Animating and stopping the animation (even eOnce) is not necessary. SetView(view,loop,frame) does the same thing.

But how do I use object.Graphic ? (And that's supposed to be before fade in right?)
Or is that obsolete?

By the way: I forgot to tell that setting the default graphic for the door as closed and leaving it alone does not work. That's because the door animates (and opens) when I leave the room and when I come back in the room, the door is still open.

Khris

object[0].Graphic=s;

Where s is the number of the sprite in the Sprite manager.

rtfm...? ;)

SMF spam blocked by CleanTalk