Jump to content


Photo

Destroying Instance On Certain Frame


  • Please log in to reply
4 replies to this topic

#1 Clyde49

Clyde49

    GMC Member

  • New Member
  • 21 posts

Posted 15 November 2008 - 12:54 AM

I was wondering if there was any way to use image_index to stop an animation or destroy an instance of an object on a certain frame.

Specifically, what i'm trying to accomplish is to have an item play an animation once, then when it reaches the final frame, be destroyed. So, i tried a peice of code like this:[codebox]
if image_index = 10
{
instance_destroy
}

[/codebox]

This seemed like it would work, but it did not. The animation simply kept repeating its animation endlessly.

Any ideas on how this can be done? On a post of mine yesterday about something similar someone referred me to a guide on making animation controller,s and while it was useful, i feel it is too complex for something this simple.

Edited by Clyde49, 15 November 2008 - 01:13 AM.

  • 0

#2 Dangerous_Dave

Dangerous_Dave

    GMC Member

  • Global Moderators
  • 9384 posts
  • Version:Unknown

Posted 15 November 2008 - 12:58 AM

There is an animation end event (found under "other"). Place the destroying code in there (and don't forget the brackets, instance_destroy() :P)

Edited by Dangerous_Dave, 15 November 2008 - 12:59 AM.

  • 0

#3 Alexander_Q

Alexander_Q

    GMC Member

  • GMC Member
  • 739 posts

Posted 15 November 2008 - 12:59 AM

I remember doing something like this. I think the problem is that the image_index has a decimal value for some reason. Try:

if image_index >= 10  //or
if floor(image_index) = 10

The above works too, but you might find you need to put the code somewhere other than in the animation end event.

Edited by Alexander_Q, 15 November 2008 - 01:01 AM.

  • 0

#4 Clyde49

Clyde49

    GMC Member

  • New Member
  • 21 posts

Posted 15 November 2008 - 01:08 AM

Oh, alright. Thanks to both of you! I'm about to try those out!
  • 0

#5 Clyde49

Clyde49

    GMC Member

  • New Member
  • 21 posts

Posted 15 November 2008 - 01:13 AM

Both solutions actually work like a charm! Thanks a ton you guys!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users