Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Krosad on May 04, 2011, 07:30:08 PM

Title: About sprite animation
Post by: Krosad on May 04, 2011, 07:30:08 PM
Hello!

How work Play() and Reset() ?

I have sprite with no loop animation, and i need play it on "LeftClick".
Title: Re: About sprite animation
Post by: Mnemonic on May 05, 2011, 05:52:48 PM
Can't you simply use entity.PlayAnim() ? Using the sprite scripting methods is an advanced technique and isn't necessary for everyday use.
Title: Re: About sprite animation
Post by: Krosad on March 03, 2012, 08:28:08 PM
How to stop animation at a certain frame?
Title: Re: About sprite animation
Post by: Mnemonic on March 11, 2012, 10:13:11 AM
You'd need to attach a script to the sprite and handle the 'FrameChanged' event in it.

Code: WME Script
  1. on "FrameChanged"
  2. {
  3.   if (this.CurrentFrame == 10) this.Pause();
  4. }
  5.  
Title: Re: About sprite animation
Post by: Krosad on August 04, 2012, 06:41:28 PM
Hi,

 I`ve got some problem with sprites.

I create noloop anim sprite in scene_init.script.
Code: [Select]
global indicator = Scene.GetNode("indicator");
global indicator_sp = indicator.GetSpriteObject();
indicator_sp.Pause();

.. then in indicator.script

Code: [Select]
on "LeftClick" {indicator_sp.Play();}
After animation, indicator sprite change color from green to red.
Then actor goes to another scene and back, indicator is green again (!?).
How to fix this?

Title: Re: About sprite animation
Post by: Krosad on August 06, 2012, 09:07:22 AM
I still trying to solve this problem
i add global variable ind_act = 1 if sprite was animated.

in scene_init.script

Code: [Select]
global indicator = Scene.GetNode("indicator ");
global ind_act;
global indicator _sp = indicator .GetSpriteObject();
if(ind_act == 1)
{
indicator _sp.CurrentFrame = 6;      // 6 - last frame
indicator _sp.Pause();
}
else indicator _sp.Pause();

i thought it must work, but WME give fatal error.
Title: Re: About sprite animation
Post by: Jerrot on August 06, 2012, 09:27:45 AM
Hi,

first of all, when talking about errors WME throws, please also quote the error here. :-)

global indicator _sp = indicator .GetSpriteObject();
if(ind_act == 1)
{
indicator _sp.CurrentFrame = 6;      // 6 - last frame
indicator _sp.Pause();
}
else klawa_sp.Pause();

From what I can see immediately: you have a blank in your variable name between "indicator" and "_sp", that shouldn't be there. This will surely throw a fatal compile error.
Title: Re: About sprite animation
Post by: Krosad on August 06, 2012, 09:37:07 AM
i did a blank, when i wrote this post, in scripts no blanks.


about errors WME throws. WME just don`t respond on Esc and i had to used ctrl+alt+del.

Code: [Select]
-----------------------------------------------------------------
---------- wme 1.9.001 crash report: 06-08-2012, 14:41 ----------
-----------------------------------------------------------------
wme.exe caused a EXCEPTION_ACCESS_VIOLATION in module wme.exe at 001B:00000000
EAX=00000000  EBX=04E418A0  ECX=04E3E808  EDX=04E58C40  ESI=00000000
EDI=0000000C  EBP=04E4CDB0  ESP=0012FD60  EIP=00000000  FLG=00010202
CS=001B   DS=0023  SS=0023  ES=0023   FS=003B  GS=0000
Stack trace:
001B:00000000 (0x04E4CDB0 0x0C5F471E 0x0000000C 0x00000017) wme.exe
001B:00440162 (0x656D6172 0x090C0C00 0x00030011 0x0208013B) wme.exe
001B:46746E65 (0x00000000 0x00000000 0x00000000 0x00000000) <UNKNOWN>
Title: Re: About sprite animation
Post by: Krosad on August 06, 2012, 10:03:50 AM
I think I found what It was.
Sprite must be set on next-to-last frame.