Jump to content


Photo

End Animation Help


  • Please log in to reply
19 replies to this topic

#1 Corngamer

Corngamer

    GMC Member

  • GMC Member
  • 137 posts
  • Version:GM8

Posted 15 June 2012 - 10:18 PM

I am making a game where the player can die in multiple ways. When you die, a death animation plays where the player spins around and falls on the ground. But I don't know how to make the animation play only once. I know that there's an Animation End event, but that's for EVERY time an animation ends, and my character also has a walking animation. What do I need to do?

Also, can you give me the answer in Drag N Drop commands, if possible. I get confused with code.
  • 0

#2 millzyman

millzyman

    GMC Member

  • GMC Member
  • 560 posts
  • Version:Unknown

Posted 15 June 2012 - 10:37 PM

Hmm it is soo much easier in code though :P

Okay so you want to check which animation you are using, that should fix the Animation End event problem

So just check if the variable sprite_index equals your dying animation.

It is the purple hexagon saying var in it, that is the one that you want. :GM073: - thats the one. So fill in the following details for it:

name: sprite_index
value: *dying animation here*
operation: equals to

then after it use the variable set D&D command :GM074: and fill it in as

name: image_speed
value: 0


p.s. Incidentally through code it is:

if (sprite_index == *dying_animation_here*){
image_speed = 0;
}

Edited by millzyman, 15 June 2012 - 10:39 PM.

  • 2

#3 Corngamer

Corngamer

    GMC Member

  • GMC Member
  • 137 posts
  • Version:GM8

Posted 15 June 2012 - 10:57 PM

I did this and the game presents me with this error (BTW my character's name is Exploro):

ERROR in
action number 1
of Other Event: Animation End
for object obj_Exploro:

Error in expression:spr_Exploro Death
position 1: Unknown variable spr_Exploro
  • 0

#4 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1092 posts
  • Version:GM7

Posted 15 June 2012 - 11:36 PM

The variable is sprite_index. The value should be tested as spr_Exploro_Death (No spaces. Never have spaces, it's like setting an object to solid.)
  • 1

#5 annihilator127

annihilator127

    GMC Member

  • GMC Member
  • 143 posts
  • Version:GM8

Posted 16 June 2012 - 02:08 AM

Expressions are parsed in action properties the same way as in GML code.
This means that you can't use spaces and certain symbols in resource names if you do this.

You have two choices: either rename the sprite (recommended) or use its numeric index (which you can find by typing its name as a watch expression in debug mode).

There's a menu command to check the validity of your resource names: Scripts > Check Resource Names.
  • 1

#6 millzyman

millzyman

    GMC Member

  • GMC Member
  • 560 posts
  • Version:Unknown

Posted 16 June 2012 - 02:10 AM

Edit: the guy above explained it.

Edited by millzyman, 16 June 2012 - 02:12 AM.

  • 0

#7 Corngamer

Corngamer

    GMC Member

  • GMC Member
  • 137 posts
  • Version:GM8

Posted 16 June 2012 - 04:05 PM

Expressions are parsed in action properties the same way as in GML code.
This means that you can't use spaces and certain symbols in resource names if you do this.

You have two choices: either rename the sprite (recommended) or use its numeric index (which you can find by typing its name as a watch expression in debug mode).

There's a menu command to check the validity of your resource names: Scripts > Check Resource Names.


I renamed the sprite, but now the game won't play the animation all the way through.

Edit:
I fixed that problem (I had an event in the wrong place), but other events still affect the object (i.e. if you press the walk button you start moving; other objects that cause death will cause the animation to repeat). How can I make it so that no other events affect the object?

Edited by Corngamer, 16 June 2012 - 04:09 PM.

  • 0

#8 GMKn00b

GMKn00b

    GMC Member

  • GMC Member
  • 150 posts
  • Version:Unknown

Posted 17 June 2012 - 06:25 AM

Here's a very easy way.

Just have a change instance (make another object with dying sprite) :GM025:
Then in the dying object have an animation end>destroy instance
(or some other stuff you want to happen when you die, like show highscore) :thumbsup:
  • 2

#9 Corngamer

Corngamer

    GMC Member

  • GMC Member
  • 137 posts
  • Version:GM8

Posted 18 June 2012 - 07:39 PM

Here's a very easy way.

Just have a change instance (make another object with dying sprite) :GM025:
Then in the dying object have an animation end>destroy instance
(or some other stuff you want to happen when you die, like show highscore) :thumbsup:

That works. Thanks!

One more thing. When the player touches an object that causes death, I want everything on the screen to stop moving except for the player. How can I do this? I know I can just use a not move action, but I have multiple instances of the same objects.
  • 0

#10 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1092 posts
  • Version:GM7

Posted 18 June 2012 - 07:48 PM

(In the enemy parents and stuff) Check if the player death instance exists. If it does, then put in a no movement action (or set speed to 0) at the end of the step event or something for those parent objects.
  • 0

#11 GMKn00b

GMKn00b

    GMC Member

  • GMC Member
  • 150 posts
  • Version:Unknown

Posted 19 June 2012 - 07:39 AM


Here's a very easy way.

Just have a change instance (make another object with dying sprite) :GM025:
Then in the dying object have an animation end>destroy instance
(or some other stuff you want to happen when you die, like show highscore) :thumbsup:

That works. Thanks!

One more thing. When the player touches an object that causes death, I want everything on the screen to stop moving except for the player. How can I do this? I know I can just use a not move action, but I have multiple instances of the same objects.

You mean stop it from walking/moving (or you mean the sprite, gif.)?

In your character have a collision event with the object (the one that makes you die)

Then have moved fixed :GM002:

Then this is what you should put it in:
Click Applies to "Object", then select the object that you want to stop
Click the square button in middle.
Speed to 0


And there you have it :thumbsup:

//what this does is it stops ALL the obj_"whatever obj you picked" (since you said there are multiple instance of the same object)

So if you want to stop another object just add another move fixed
and do the same but change the "Applies to object" part (pick the new object you want to stop) :wink:

Edited by GMKn00b, 19 June 2012 - 07:44 AM.

  • 1

#12 Corngamer

Corngamer

    GMC Member

  • GMC Member
  • 137 posts
  • Version:GM8

Posted 21 June 2012 - 12:15 PM

Something's wrong with the death animation. If the player is touched while moving, the entire animation plays, but when the player is touched while standing still, it only goes through the first image. What do I need to do?

Edited by Corngamer, 21 June 2012 - 12:15 PM.

  • 0

#13 GMKn00b

GMKn00b

    GMC Member

  • GMC Member
  • 150 posts
  • Version:Unknown

Posted 22 June 2012 - 07:03 AM

So when the block, touches the player (the block moves?).....
....only one of the subimages is shown (only one part of animation)?

So this what you should have. (in player)
//collision with block
change instance (dying)

And (in the dying object, have the dying sprite)
//other (animation end)
delete instance

IS this what you have?

Edited by GMKn00b, 22 June 2012 - 07:19 AM.

  • 1

#14 Corngamer

Corngamer

    GMC Member

  • GMC Member
  • 137 posts
  • Version:GM8

Posted 25 June 2012 - 05:34 PM

So when the block, touches the player (the block moves?).....
....only one of the subimages is shown (only one part of animation)?

So this what you should have. (in player)
//collision with block
change instance (dying)

And (in the dying object, have the dying sprite)
//other (animation end)
delete instance

IS this what you have?

Not exactly. For the dying object, I have Create > Change sprite into dying animation, and then Animation End > Display Message (Game Over!), Show Highscore Table, Restart Game.
  • 0

#15 GMKn00b

GMKn00b

    GMC Member

  • GMC Member
  • 150 posts
  • Version:Unknown

Posted 26 June 2012 - 06:49 AM

Just delete the create event, and change the sprite
of the dying object to dying animation (instead of doing change sprite) :thumbsup:

So basically all you should have is Animation End :happy:

Edited by GMKn00b, 26 June 2012 - 06:50 AM.

  • 0

#16 Corngamer

Corngamer

    GMC Member

  • GMC Member
  • 137 posts
  • Version:GM8

Posted 26 June 2012 - 04:07 PM

Just delete the create event, and change the sprite
of the dying object to dying animation (instead of doing change sprite) :thumbsup:

So basically all you should have is Animation End :happy:

That didn't work. :sad: But I think I know what the problem is. For the change instance action (which is used to change the object to the death object), there is an option called "perform events". Should this be set to "not" or "yes"? I have it set to "not".
  • 0

#17 GMKn00b

GMKn00b

    GMC Member

  • GMC Member
  • 150 posts
  • Version:Unknown

Posted 27 June 2012 - 07:37 AM

If you did yes, it executes the original objects 'Destroy Event' turning into 'Create Event'.

If you did no, neither of those two are executed :tongue:

SOURCE
  • 1

#18 Corngamer

Corngamer

    GMC Member

  • GMC Member
  • 137 posts
  • Version:GM8

Posted 27 June 2012 - 11:37 PM

If you did yes, it executes the original objects 'Destroy Event' turning into 'Create Event'.

If you did no, neither of those two are executed :tongue:

SOURCE

Setting "perform events" to "yes" and putting the Create Event back into the death object seem to make it work. But I'm confused about what you are saying about it executing the events. :confused:
  • 0

#19 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1092 posts
  • Version:GM7

Posted 28 June 2012 - 12:53 AM

Setting perform events to true will make it so that the new object's create event (which is the event we are concerned about) is executed (hence the name perform events).
  • 1

#20 Corngamer

Corngamer

    GMC Member

  • GMC Member
  • 137 posts
  • Version:GM8

Posted 28 June 2012 - 01:06 AM

Setting perform events to true will make it so that the new object's create event (which is the event we are concerned about) is executed (hence the name perform events).

Ok, that makes sense! Thanks guys! :thumbsup:
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users