1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

About spell animation

Discussion in 'Programming' started by DarlesLSF, Sep 21, 2018.

  1. DarlesLSF

    DarlesLSF Member

    Joined:
    Sep 1, 2018
    Posts:
    61
    I want to make a spell animation like the gif below (the flame spell):

    [​IMG]

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

    Kanugane Member

    Joined:
    Sep 20, 2018
    Posts:
    29
    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.
     
  3. DarlesLSF

    DarlesLSF Member

    Joined:
    Sep 1, 2018
    Posts:
    61
    Didn't work, thats the result:

    [​IMG]

    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();
                }
    
     
  4. Kanugane

    Kanugane Member

    Joined:
    Sep 20, 2018
    Posts:
    29
    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);
    }
     
  5. DarlesLSF

    DarlesLSF Member

    Joined:
    Sep 1, 2018
    Posts:
    61
    I did everything you said, but still dont destroying the anima_ataque object, idk why
     
  6. Kanugane

    Kanugane Member

    Joined:
    Sep 20, 2018
    Posts:
    29
    Alright. Let's try this. In your step event of anima_ataque object, write the following:
    set image_index = 0 and image_speed = 1 in create event of anima_ataque_object.

    Also, remove animation end event in anima_ataque_object.
     
  7. DarlesLSF

    DarlesLSF Member

    Joined:
    Sep 1, 2018
    Posts:
    61
    Well, the problem now its when the player goes back to initial point:
    [​IMG]

    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;
           }
       
        }
    
     
  8. Kanugane

    Kanugane Member

    Joined:
    Sep 20, 2018
    Posts:
    29
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice