Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: how to stop an actor's animation when music stops?  (Read 869 times)

0 Members and 1 Guest are viewing this topic.

nakker101

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 6
    • View Profile
how to stop an actor's animation when music stops?
« on: October 22, 2016, 11:08:38 PM »

Hello to everybody.Many years passed since the last time I was trying to create a small game. I finaly decided to continue but I have a problem. In a scene there is a music player. I want "On take" to play a music,the 2D actor to go to a dance floor and start dancing and when the music stops I want the actor to stop dancing. The problem is that the music stops but the actor doesn't. The music file is an ogg file. The actor animation is a sprite with looping turn on because the animation is shorter than the music.What is the correct way for telling the game that when this particular music stops,it should stop the actor animation too? Thank you for your time.
Logged

s.belov

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 38
    • View Profile
Re: how to stop an actor's animation when music stops?
« Reply #1 on: October 23, 2016, 04:49:50 AM »

pseudo code:

Code: WME Script
  1. actor.GoTo(dance floor);
  2. any_object.PlaySound(music);
  3. actor.IdleAnimName = "dancing";
  4. while (any_object.IsSoundPlaying()) {
  5.    Sleep(1);
  6. }
  7. actor.IdleAnimName = "stop dancing";

Logged

nakker101

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 6
    • View Profile
Re: how to stop an actor's animation when music stops?
« Reply #2 on: October 28, 2016, 06:11:29 PM »

Thank you s.belov for your answer. I have more questions if you don't mind.My actor is a 2D actor. Can the "actor.IdleAnimName" be used for a 2D actor too? If it can, when you write "actor.IdleAnimName = "dancing";" and "actor.IdleAnimName = "stop dancing";" this "dancing" and "stop dancing" what exactly is it?
Logged

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 188
    • View Profile
Re: how to stop an actor's animation when music stops?
« Reply #3 on: October 29, 2016, 01:57:14 AM »

"dancing " and "stop dancing" are animation sets - which can form part of an actor definition in the same way that "talk" "walk" and "turn" are.

If you want more on this I suggest you read the section on actors in the documentation that comes with the kit.

The other and perhaps easier way to kill an animation is actor.Reset();
Logged
 

Page created in 0.154 seconds with 17 queries.