Master Cabalist
Member
How do I turn off looping for my animation of my object in the game? I can stop it in the IDE but that doesn't effect the game according to the MANUAL.
Just make image_speed 0. If you want it to do the animation once, then make image_speed 0 in the animation end event.How do I turn off looping for my animation of my object in the game? I can stop it in the IDE but that doesn't effect the game according to the MANUAL.
with (DraculaStaticObject)
{
instance_destroy();
}
instance_create_depth(352,544,-1200, DraculaAttackObject1);
with (DraculaAttackObject1)
{
if (image_number == 3)
{
instance_destroy();
instance_create_depth(300, 500, -1200, DraculaAttackObject2);
if (image_number == 8)
{
with (DraculaAttackObject2)
{
instance_destroy();
}
instance_create_depth(352, 544, -1200, DraculaStaticObject);
}
}
}
What do you mean by:image_number is not what you think I'm guessing. It simply tells you how many subimages there are in the current sprite. You may be looking for image_index instead if you are trying to check directly which frame it is on in order to destroy it. However, note that these are floating point values so may not ever end up exactly on some integer value. This is part of why I recommended instead to just use the event, it should work in all cases.
This can be even easier if you have a dedicated object that is literally just showing the animation and destroying itself, as you don't have to do any checking of anything.
This can be even easier if you have a dedicated object that is literally just showing the animation and destroying itself, as you don't have to do any checking of anything.
I mean that if you are using a single object that does mutliple things, you will have to keep checking inputs or whatever the object does. But if the object is a "clone" of sorts and is only for the purpose of displaying the animation and that's it, then it is extremely easy to just use the animation end event and destroy itself as you wouldn't be needing any other events, and wouldn't need to do anything else in the animation end event either.What do you mean by:
Well the objects are sort of clones. I had to split them up because the frame sizes were drastically different for the single sprite. Anyway, it's done and working. ThanksI mean that if you are using a single object that does mutliple things, you will have to keep checking inputs or whatever the object does. But if the object is a "clone" of sorts and is only for the purpose of displaying the animation and that's it, then it is extremely easy to just use the animation end event and destroy itself as you wouldn't be needing any other events, and wouldn't need to do anything else in the animation end event either.
Regardless of whether it should beGML:instance_create_depth(352,544,-1200, DraculaAttackObject1); with (DraculaAttackObject1) { if (image_number == 3) { instance_destroy(); instance_create_depth(300, 500, -1200, DraculaAttackObject2); if (image_number == 8) { with (DraculaAttackObject2) { instance_destroy(); } instance_create_depth(352, 544, -1200, DraculaStaticObject); } } }
image_number
or image_index
... if (image_number == 3) // if this is true
{
...
if (image_number == 8) // this will not be true
{
... // this will never execute
}
}
I agree with the potential for the number to change, as in theory you could make your create event code do anything you want, including modifying the sprite_index for a different instance. I also agree with the problematic logic of having destruction of the current instance in the middle of execution (not to be confused with in the middle of code, I try to ensure destruction at the end of an event, but that doesn't mean it is lexically at the end of the code). Regardless of what the semantics are, documented or not, I prefer to think of destruction as the last thing an instance should be involved with (exceptions may exist, I just haven't had much need for that myself).To be fair, if sprite_index changes, then image_number could potentially change between those checks, but that's not the case here, and it's almost certain (as has been said) that image_number isn't the variable they intended to use. There's a bigger problem here, though, in that the instance_destroy call comes before the second check, so it's checking a variable in a destroyed instance. I think that's supposed to be okay, since the event continues until the destroyed instance goes out of scope, but I would recommend avoiding that as a matter of practice.
if (global.dracula_attacking == false)
{
if (mouse_check_button_released(mb_left))
{
//Last BOSS Attacked
//if mouse_x < 1024 && mouse_x > 0 && mouse_y > 0 && mouse_y < 576
//{
global.dracula_atttacking = true;
with (DraculaStaticObject)
{
instance_destroy();
}
instance_create_depth(352,544,-1200, DraculaAttackObject1);
//}
}
}
// You can write your code in this editor
image_speed = 0;
instance_create_depth(352, 544, -1200, DraculaStaticObject);
global.dracula_attacking = false;
instance_destroy();
global.dracula_attacking = false;
global.dracula_atttacking = true;
Any reason it might not do that?2. There isn't any real reason unless either the code is never being reached, or you are setting it to false somewhere else and not even noticing because it happens so fast. You can add show_debug_message() to the code to see if it is ever being reached.So I ran it through the debugger and its not settingglobal.dracula_atttacking = true;
Any reason it might not do that?