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.

Pages: [1] 2  All

Author Topic: How to check if a sprite is running and stop it?  (Read 11757 times)

0 Members and 1 Guest are viewing this topic.

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
How to check if a sprite is running and stop it?
« on: March 08, 2008, 05:28:51 PM »

Hi all

I set a sprite running in an entity like this:
a = "MySprite.sprite";
b = Scene.GetNode("SpritePlace");
b.SetSprite(a);

Which works fine, but I can't figure out how to check if the sprite is running and then stop it. I guess it must be something to do with querying the entity? I've put 'Stop Sprite running' into the forum, but nothing seems to point me to the answer. Can anybody help?

Thanks

Kaz
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: How to check if a sprite is running and stop it?
« Reply #2 on: March 08, 2008, 06:40:12 PM »

Thanks Metamorphium

The effect I'm trying to achieve is "If this, then do that - if any sprite is running in node subx, stop it." I tried to make the code you pointed me work like an 'if', thus:
b = null;
a = Scene.GetNode("subx");
b = a.GetSpriteObject();
if(b != null)
  {
  b.Reset();
  }
Doesn't work, the sprite in subx keeps playing. Thanks for the assistance and forgive me for being unable to implement it. Any pointers gratefully accepted.

Regards

Kaz
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: How to check if a sprite is running and stop it?
« Reply #3 on: March 09, 2008, 01:00:55 PM »

Reset() doesn't prevent the sprite from starting to play over again. You might need to do something like:

b.Reset();
b.Pause();

Or just b.Pause() for that matter. Depends on the effect you need to achieve.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: How to check if a sprite is running and stop it?
« Reply #4 on: March 16, 2008, 09:22:41 AM »

Actually, what I'm mainly looking for is what to check to see if the sprite is running. Can anybody tell me plase what should be in my
'if' statement to test whether or not a sprite is running?

Thanks
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Jyujinkai

  • Global Moderator
  • Frequent poster
  • *
  • Karma: 1
  • Offline Offline
  • Posts: 352
    • View Profile
    • Jyujinkai's WME Development Blog
Re: How to check if a sprite is running and stop it?
« Reply #5 on: March 16, 2008, 09:33:47 AM »

i keep reading your avatar as "studio afterbirth" lol sorry just thought it was funny... must be my dyslexia.
Logged
<Antoine de Saint-Exupéry> In any thing at all, perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away...
<Carl Sagan> If you want to make a apple pie from scratch. You must first... invent the universe

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: How to check if a sprite is running and stop it?
« Reply #6 on: March 16, 2008, 10:01:15 AM »

The sprite is always running, unless it finished (and doesn't loop) or unless you paused it. So the "if" would look something like this:

Code: WME Script
  1. var Sprite = SomeEntity.GetSpriteObject();
  2. if(!Sprite.Finished && !Sprite.Paused) // NOT finished AND NOT paused
  3. {
  4.   // sprite is animating
  5. }
  6.  
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: How to check if a sprite is running and stop it?
« Reply #7 on: March 16, 2008, 02:13:55 PM »

Hi Mnemonic

Thanks for that. Put that way, looks obvious :-)

Can you please point me to where I'd find that in the documentation? I'd prefer not to ask daft questions when the answer is already catered for in the script engine.

Thanks

Kaz
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: How to check if a sprite is running and stop it?
« Reply #8 on: March 16, 2008, 02:29:33 PM »

The sprite properties are described in Scripting in WME -> Script language reference -> Sprite object.
But don't worry about asking questions. That's what the forum is for.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: How to check if a sprite is running and stop it?
« Reply #9 on: March 16, 2008, 03:17:49 PM »

Nope. that didn't work

This sprite is relentless. No matter what I throw at it, it just keeps going. It's a message on an answering machine, subtitles and sound in one sprite. I put it into Node "subx" with a 'SetSprite' and then check if it is running- with a view to stopping it if it is. My code is:

// Are we listening to a message?
a = Scene.GetNode("subx");
m = ItemNormal.GetSpriteObject();
if(m.Finished == false && m.Paused == false)
  {
  Game.Msg("I'm not finished");
  Game.StopSound();
  m.Reset;
  m.Pause;
  }
But it just trundles on. This is how much hair I had before I started writing this script.  O0 This is me now.  ???  I tried to copy the hints Mnemonic and Metamorphium gave me and I've read everything I can find. What am I doing wrong?

Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: How to check if a sprite is running and stop it?
« Reply #10 on: March 16, 2008, 03:23:51 PM »

Oops

Din't complete edit b4 sending - code should read

// Are we listening to a message?
a = Scene.GetNode("subx");
m = a.GetSpriteObject();
if(m.Finished == false && m.Paused == false)
  {
  Game.Msg("I'm not finished");
  Game.StopSound();
  m.Reset;
  m.Pause;
  }
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: How to check if a sprite is running and stop it?
« Reply #11 on: March 16, 2008, 03:27:52 PM »

does the message appear? Does the script run at all? Any errors in the log file?
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: How to check if a sprite is running and stop it?
« Reply #12 on: March 16, 2008, 03:29:28 PM »

So the message doesn't display?
Those two last lines should read:

m.Reset();
m.Pause();

They are methods, not properties, therefore they require parameters even if there are none (-> empty parenthesis).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Kaz

  • Arberth Studios
  • Regular poster
  • ***
  • Karma: 1
  • Offline Offline
  • Posts: 228
  • The story is the game
    • View Profile
    • Info on 'Rhiannon' & 'Coven'
Re: How to check if a sprite is running and stop it?
« Reply #13 on: March 16, 2008, 04:05:31 PM »

Oops with the brackets. Put them in, but the sprite still rolls merrily on. The script is running because I see the Game.Msg.

I've even tried disabling the Node that carries the sprite, but the message and subtitles keep coming no matter how often I go through the routine.
Logged
\"Fans of popular horror adventures like Scratches and Barrow Hill should start bracing themselves for another haunting experience, as independent developer Arberth Studios has announced production on its debut title Rhiannon - Curse of the Four Branches.\" - AdventureGamers.com

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: How to check if a sprite is running and stop it?
« Reply #14 on: March 16, 2008, 04:17:51 PM »

Well I tried the following code in WME Demo and it definitely does work:

Code: WME Script
  1.   var Fan = Scene.GetNode("fan");
  2.   var Sprite = Fan.GetSpriteObject();
  3.  
  4.   if(!Sprite.Finished && !Sprite.Paused)
  5.   {
  6.     Sprite.Reset();
  7.     Sprite.Pause();
  8.   }
  9.  
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
Pages: [1] 2  All
 

Page created in 0.09 seconds with 21 queries.