Please login or register.

Login with username, password and session length
Advanced search  

News:

For WME related articles and tutorials visit WME Resource Center.

Pages: 1 [2]  All

Author Topic: How to check if a sprite is running and stop it?  (Read 11759 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'
Re: How to check if a sprite is running and stop it?
« Reply #15 on: March 16, 2008, 05:02:35 PM »

Hi,

I've attached the whole script - because now the game just gives me a run-time error and says that 'Pause' is not defined.

I'm completely at a loss.

#include "scripts\base.inc"
//
global gNextMessageToPlay;
global gHeardMessage1;
var a;
var Sprite;
Game.AttachScript("scenes\04_Lounge\ANSAPHONE\scr\MessagePlay.script");
//
on "LeftClick"
  {
  // Disable exit
  a = Scene.GetNode("zoom_out");
  a.Active = false;
  //
  Game.PlaySound("sounds\LittleSwitch.ogg");
  Sleep(500);
  // Are we listening to the bleep?
  a = Game.IsMusicChannelPlaying(1);
  if(a == true)
    {
    Game.StopMusicChannel(1);
    }
  //
  // Are we listening to a message?
  a = Scene.GetNode("subx");
  Sprite = a.GetSpriteObject();
  if(!Sprite.Finished && !Sprite.Paused)
    {
    Game.Msg("I'm not finished");
    Sprite.Pause();
    }
  else
    // if we can't hear a message, time to play one
    {
    if(gHeardMessage1 == false)
      {
      gNextMessageToPlay = 1;
      Game.MessageNumber();
      }
    Game.PlayMessage();
    }
  }
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 #16 on: March 16, 2008, 06:21:04 PM »

are you sure the entity in question is Sprite Entity and is called subx (don't forget it's case SENSITIVE)?
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 #17 on: March 17, 2008, 02:46:37 PM »

Hi Metamorphium,

Yes I'm sure about that. The code that runs the sprite is in another part of the Attached script, and it must be working, because the sprite plays its designated mixture of subtitles and voiceover:
var Sprite;
var a;
global gNextMessageToPlay;
  if(gNextMessageToPlay == 1)
    {
   gHeardMessage1 = true;
    Sprite = "scenes\04_Lounge\ANSAPHONE\TommyANSA1.sprite";
             a = Scene.GetNode("subx");
   a.SetSprite(Sprite);
   a.Active = true;
    }
So if I'd got the case wrong relative to the scene entity, it wouldn't play, let alone stop, right?

Cheers
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 #18 on: March 21, 2008, 08:47:48 AM »

I've given up on this one. I'll find another way of playing the messages. Still don't know why I couldn't control the sprite though, which is disconcerting.
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

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re: How to check if a sprite is running and stop it?
« Reply #19 on: March 21, 2008, 09:36:15 AM »

As a last resort you can upload the sources of a simple test scene. It's always the best method to check what's going on. And if you don't want to do this in public you can send the link in a pm to Mnemonic.
Logged
fl*p

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 #20 on: March 21, 2008, 11:27:47 AM »

or send a PM to me for that matter. The problem will be elsewhere IMO and having some minimalistic testing scene would help.
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 #21 on: March 22, 2008, 01:56:47 PM »

Interesting new development. Thanks for the idea to create a minigame, it's definitely thrown up something...

In order to create the minigame, I had to rebuild the sprite. Half a dozen timed frames, with a sound file connected to the first frame. Set that running in SpriteEdit. Then press the 'stop' button. The animation stops, but the sound keeps going! So even SpriteEdit cannot stop the attached sound - so I'm less surprised now that I couldn't stop the sprite in the game either. Could that be a bug?

In any case, although sprites would be a convenient way of handling this scene, the sound handling seems suspect. I guess I'll take the sound out and control it separately with a MusicChannel. That way I can do an IsMusicChannel and if it's true, do a StopMusicChannel at the same time as an ent.Active=false on the node carrying the subtitles (after resetting the node's sprite of course).

Thanks for all your help guys.

Cheers

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.
Re: How to check if a sprite is running and stop it?
« Reply #22 on: March 22, 2008, 09:39:15 PM »

is the sound ogg or wav?
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 #23 on: March 22, 2008, 10:51:25 PM »

I didn't realize Kaz was talking about sprite's sound all the time.
Now I modified the Sprite.Reset() method so that it also stops all sounds being played by the sprite.
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 #24 on: March 23, 2008, 12:02:19 PM »

Hello M and Mn

The sound is an ogg. Thanks for looking at the method.

One last thing: what do I need to do to stop getting this:

11:00:34:  Runtime error. Script 'scenes\04_Lounge\ANSAPHONE\scr\Play.script', line 33
11:00:34:    Call to undefined method 'Reset'. Ignored.


from this code?
   a = Scene.GetNode("subx");
   Sprite = a.GetSpriteObject();
   Sprite.Reset();


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 #25 on: March 23, 2008, 12:05:49 PM »

You'll get this error if the sprite object reference isn't valid. Try this:

if(Sprite != null) Sprite.Reset();
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 #26 on: March 23, 2008, 12:24:29 PM »

Ah, I hadn't thought of that, thanks. Although I guess it would be better if my code was written so I didn't make the error of addressing an empty Node in the first place!  :-[

I'll recheck my logic.
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
Pages: 1 [2]  All
 

Page created in 0.048 seconds with 23 queries.