Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Controling sprite animation frame  (Read 2787 times)

0 Members and 1 Guest are viewing this topic.

helios

  • Supporter
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 41
    • View Profile
Controling sprite animation frame
« on: January 21, 2007, 07:10:15 PM »

Hi,

I have a problem controlling sprite animation frame.
At the start, lets say, in scene A, there is a door (with an opening animation paused on first frame) and the player must open it so he can go to scene B. Once in B, he can decide to come back to scene A, and when it happens, the scene A is loaded with the door closed again.

So, is there a way to tell an animation to load in the last frame? If yes, I could set that if it comes from scene B, the door sprite goes to its last frame, else it goes to frame 1 and pauses.

If not, how should I do this? Delete the sprite (how again, since I tried it before and didn´t succed - the solution in my first problem was to make the other animation not active)? What else?

Thanks,
Helios
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Controling sprite animation frame
« Reply #1 on: January 21, 2007, 08:05:53 PM »

there are several ways how to do this.

I'd do the following:

you have two animations and one overlays let's say:

Main background has closed door, you have animation of opening the door, animation of closing the door and overlay of door being open.
Then if player opens the door you do something like this:

Code: [Select]
var tmp = Scene.GetNode("anim_open");
tmp.Active = true;
tmpAnim = tmp.GetSpriteObject();
tmpAnim.Reset(); // this displays the animation of door opening.
while (!tmpAnim.Finished) Sleep(1); // wait for the animation to end.
tmp.Active = false; // hide the animation
tmp = Scene.GetNode("door_open");
tmp.Active = true; // display the open door overlay.

Identical would have been close only with hiding overlay and playing the second animation.

Now when you enter the room, you simply put to your Scene_init.script

Code: [Select]
var e = Scene.GetNode("door_open");

if (RoomXDoorOpen)  //we set some variable whenever actor opens or closes the door to true or false respectively.
  e.Active = true;
else
  e.Active = false;



Hope this helps.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Controling sprite animation frame
« Reply #2 on: January 21, 2007, 09:59:12 PM »

Maybe I'm missing something, but I think it would be easiest to create three sprites: 1) closed door 2) open door 3) opening door animation

Initially the scene would contain closed door.
Once the player opens the door, you'd call:

var Door = Scene.GetNode("door");
Door.PlayAnim("door_opening.sprite");
Door.SetSprite("open_door.sprite");

When revisiting the scene, it will remember the last assigned sprite, i.e. open_door.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

helios

  • Supporter
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 41
    • View Profile
Re: Controling sprite animation frame
« Reply #3 on: January 22, 2007, 01:53:06 PM »

Thanks a lot guys,

Worked fine. I opted for what Mnemonic said, cause it´s more simple, but thanks for the help too metamorphium.

Gotta thanks you for all support you are giving, always very quickly. This is my first game not in Flash, and this is the second software I use. In the first, other than the bugs, I had very slow support, had to wait a week to have my questions answered. Another great point of your software is the help, that is good.

That´s it for now. Untill next doubt! :)
Logged
 

Page created in 0.037 seconds with 23 queries.