Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Sprite Entity Animation Autoplays at Startup?! Why  (Read 4621 times)

0 Members and 1 Guest are viewing this topic.

Veritas

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 4
    • View Profile
Sprite Entity Animation Autoplays at Startup?! Why
« on: November 06, 2009, 11:40:54 AM »

Hey Guys,
i am really new to wintermute. I try to set up a scene, where the character can interact with a "Toilet Flush pull".
I am not very used to oop, therefore i read through the code of the wintermute demo and took snippets of the fan.script.

I set up the Values for the ToiletFlush, just that the animation is not looping and the starting value is "false" in the initscene.script.
It works, but the problem is, the animation plays automtically once, everytime i press F5. Are there some options in the Editor i have forgotten?


Scene_Init
Code: [Select]
#include "scripts\base.inc"

// here comes the stuff which initializes the scene

actor.SkipTo(400, 400);
actor.Direction = DI_DOWN;
actor.Active = true;


////////////////////////////////////////////////////////////////////////////////
// scene state
global StateTestraum;


// default values
if(StateTestraum==null)
{
  StateTestraum.Visited = false;
  StateTestraum.Flush = 0;        //             <----     like the FanSpeed Variable in the Demo
  // add scene states here
}



////////////////////////////////////////////////////////////////////////////////
// setup scene according to state variables



////////////////////////////////////////////////////////////////////////////////
if(!StateTestraum.Visited)
{
  StateTestraum.Visited = true;

  // this is our first visit in this scene...
}


ToiletFlush.scene

Code: [Select]
#include "scripts\base.inc"

global StateTestraum;

on "LeftClick" // just leftclick --> now submenue with rightclick
{
  actor.GoToObject(this);
  Game.Interactive = false;
 
  // get the ToiletEntity
  var EntToiletFlush = Scene.GetNode("ToiletFlush");
 
  // set the ToiletFlush Pull entity sprite depending on the state variable
  // (0= not used, 1 = used)
  if(StateTestraum.Flush==0)
  {
    actor.Talk("It's turned off. I'll turn it on...");
    actor.PlayAnim("actors\Volgar\rr\take1.sprite");
    EntToiletFlush.PlaySound("sounds\Toilet.ogg");
    EntToiletFlush.SetSprite("scenes\Testraum\sprites\ToiletFlush.sprite"); <--- animation and Sound are autoplayed at startup, why?!
    actor.PlayAnim("actors\Volgar\rr\take2.sprite");
StateTestraum.Flush = 1; // save the new fan state
}

   Game.Interactive = true;
 
}

By the way, i realized at moment, if you change the Value FanSpeed to 0 in the Demo ( to not running), the startsound of the Fan is hearable there as well for the startup and then dissapears.

Hope you can tell me what i've missed.
best regards Veritas

Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Sprite Entity Animation Autoplays at Startup?! Why
« Reply #1 on: November 06, 2009, 12:00:05 PM »

You will need to use two sprites. One for the flushing animation, and one, static, with just the toiled flushed.


entity.PlayAnim("flushing.sprite");
entity.SetSprite("flushed.sprite");

Then when you revisit the scene, only the "flushed" sprite will be set.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Veritas

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 4
    • View Profile
Re: Sprite Entity Animation Autoplays at Startup?! Why
« Reply #2 on: November 06, 2009, 02:53:32 PM »

AH!, I did find the Mistake i guess, i already knew somehow what to do, but not how. Thanks Anyways  :)

---> If i want an interactive Object with animation, i DO NOT? put the AnimationSprite directly onto the Scene.
       I have to take a single picture out of the animation i want to have as "static" picture and then link the script to the animation sprite right?
       Damn, took me half a day to understand why it is playing at startup.


 best regards Veritas, somehow i get used to it  :)
« Last Edit: November 06, 2009, 02:58:47 PM by Veritas »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Sprite Entity Animation Autoplays at Startup?! Why
« Reply #3 on: November 06, 2009, 03:09:06 PM »

If you leave a scene, everything is destroyed, including the sprites. When you revisit the scene, it's all reinstated, but the sprites don't remember where they stopped playing the last time, they simply start from the beginning.

If you wonder why, consider this: if every single animation in the game should remember its complete state, it would be a LOT of data to be stored in the memory all the time. Remember, it's not only about the current animation frame, you can, in theory, dynamically change lots of properties of the animation and its individual frames.
Usually it's not needed anyway. So when it IS needed, like in your case, you'll have to handle it yourself.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.04 seconds with 20 queries.