Windows (solved)image_index and hitbox

Discussion in 'Programming' started by jonjons, Apr 16, 2019.

  1. jonjons

    jonjons Member

    Joined:
    May 10, 2017
    Posts:
    293
    hello
    i cant seem to match the time witn an obj_hitBox and the player image_index...

    there seems to be some kind of delay

    create ev
    Code:
    //----//--hit-box--//-------
    atkBox = instance_create_layer(x, y, "instances", obj_hitBox1);
    step ev
    Code:
    //--current-state
            case 6: //-----6-ATTACK-STAND-1----------
                canMove = 0;
                image_speed = 2;
                src_Animation(11, 14, 0); //-begin-end-loop-
            
                if ( image_index == 14  )
                {
                    image_index = 0;
                    playerState = 0; //--idle
                }
    
    
    //---//--ATTACK-BOXES--//------------
    
    if ( image_index >= 12 && image_index <= 13)
    {
        atkBox.hBox_x = 2;
        atkBox.hBox_y = -54;
        atkBox.hBox_w = 26;
        atkBox.hBox_h = 14;
    }
    else
    {
        atkBox.hBox_x = 0;
        atkBox.hBox_y = 0;
        atkBox.hBox_w = 0;
        atkBox.hBox_h = 0;
    }
    I dont know if the image index starts at 1 or 0, iam assuming it starts at 0.
    there seems to be some kind of delay the atkBox disapears in the middle of image_index 13
    if i set a lower image_speed 0.5 everything seems to work fine....
    Is the image_speed faster or slower than the step event ?
    if so how can i get this work ?
     
  2. jonjons

    jonjons Member

    Joined:
    May 10, 2017
    Posts:
    293
    found the solution
    it seems image_index is a timer it counts image_index 13.04 until the next image_index

    13 is not <= 13.60
    however 13.45 is...

    this way works
    Code:
    if ( image_index >= 12 && image_index < 14)
    {
        atkBox.hBox_x = 2;
        atkBox.hBox_y = -54;
        atkBox.hBox_w = 26;
        atkBox.hBox_h = 14;
    }
     

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