About spell animation

D

DarlesLSF

Guest
I want to make a spell animation like the gif below (the flame spell):



How can I do that? Creating a sprite from the flames and animate it and the next step its creating an object?
 
K

Kanugane

Guest
Make a sprite, assign it to the object with image_speed and in animation end event, tell the object to destroy. - that's a simple answer.
 
D

DarlesLSF

Guest
Didn't work, thats the result:



and here its the code:
Code:
if (global.atacando_inimigos == true) && (global.inimigo_atual == 1)
{
    global.aff_normal = false;
    sprite_index = spr_aff_atacando1;
    image_speed = spd;
    if distance_to_point(obj_inimigo1.x, obj_inimigo1.y) > 70
    {
        move_towards_point(obj_inimigo1.x - 70, obj_inimigo1.y  + 20, 20);
    } 
        else 
        { 
            speed = 0;
            sprite_index = spr_aff_atacando2;
            instance_create(obj_inimigo1.x, obj_inimigo1.y, anima_ataque_normal);    //creating the object
            anima_ataque_normal.sprite_index = anim_ataque_normal;     // setting the sprite
            anima_ataque_normal.image_speed = 3;
            alarm[0] = 2 * room_speed;     // I created a alarm because the GM performs too fast the commands 
                     
        }
   
}
and here the event to destroy the object (inside of the alarm):

Code:
with (anima_ataque_normal)
            {
                instance_destroy();
            }
 
K

Kanugane

Guest
Let's see...
Remove anima_ataque lines after you create the object. You also don't need an alarm here.
In create event of anima_ataque set image_speed to 3. (Maybe it is too fast? Try with 1 or 2 for the start).
In animation end of anima ataque set instance_destroy();

hmm. Now that I think about it. It seems that your sprite just doesn't disappear after it has been created. So you have an issue with instance_destroy code. An alternative way to fix this would be in alarm event:
if (instance_exists(anima_ataque_normal)){
instance_destroy(anima_ataque_normal);
}
 
D

DarlesLSF

Guest
Let's see...
Remove anima_ataque lines after you create the object. You also don't need an alarm here.
In create event of anima_ataque set image_speed to 3. (Maybe it is too fast? Try with 1 or 2 for the start).
In animation end of anima ataque set instance_destroy();

hmm. Now that I think about it. It seems that your sprite just doesn't disappear after it has been created. So you have an issue with instance_destroy code. An alternative way to fix this would be in alarm event:
if (instance_exists(anima_ataque_normal)){
instance_destroy(anima_ataque_normal);
}
I did everything you said, but still dont destroying the anima_ataque object, idk why
 
K

Kanugane

Guest
Alright. Let's try this. In your step event of anima_ataque object, write the following:
if (image_index > image_number - 1){
instance_destroy();
}
set image_index = 0 and image_speed = 1 in create event of anima_ataque_object.

Also, remove animation end event in anima_ataque_object.
 
D

DarlesLSF

Guest
Well, the problem now its when the player goes back to initial point:


here's the code:
Code:
if (distance_to_point(global.posxaff, global.posyaff)) > 0
    {
       move_towards_point(global.posxaff, global.posyaff, 20);
    }
    else
    {
       speed = 0;
       global.aff_normal = true;
       with (obj_inimigo1)
       {
           image_blend = c_white;
       }
   
    }
 
K

Kanugane

Guest
I personally would use switch function with multiple states. For example, idle, melee_attack, range_attack. Where in idle I would define where the player should stand and if the player executes an attack, at the end of it, you should declare the idle state again. That's all I could think of it in the morning. Using a lot -if- statements may make the code look a little more messy.
 
Top