SOLVED Hard time with controls from pc to android

Fabseven

Member
Hello,
I am trying to move my project to android from computer.

So i am changing controls , in my ways, to do so.
In my obj_hero i check vk_up , vk_down, vk_left, vk_right to move
In order to make the hero move with the mouse (or android click) if made a + in the gui and while pressing the key on the direction the hero move.
It's working fine BUUUUUT there is still a problem.

If i hold my click while on right direction and release it on up direction, the obj_hero is moving right no STOP, i donot understand why....

Code:
///in obj_system (simpleton making the game run)
///android_bf == true key for press key => simulation of vk_down,right,left,up , the vk_key is in [i,4]
if(android_bf)
{
    xxxx = device_mouse_x_to_gui(0)
    yyyy = device_mouse_y_to_gui(0)
    bbbb = mouse_check_button_pressed(mb_left)        
    stop = false
    
    for(i=0;i< array_height_2d(zzbfand);i++)
    {
        if(point_in_rectangle(xxxx,yyyy,zzbfand[i,0],zzbfand[i,1],zzbfand[i,2],zzbfand[i,3]))
        {
            if(bbbb and stop == false)
            {
                stop=true
                show_debug_message("bf pressed")
                
                keyboard_key_press( zzbfand[i,4])
                
            }
        }
        
    }
    
    
    
}
obj_hero, moving code (with others stuff, see purple text)
Code:
///atk or move four direction + AIM MODE
if( battle == false)
{
    return 0
}

if(alarm[10] <= 0) { speed=0;}//recoil to zero

//speed=clamp(speed-0.05,0,speed) 

var right = keyboard_check(vk_right)
var left  = keyboard_check(vk_left)
var up   = keyboard_check(vk_up)
var down = keyboard_check(vk_down)

/*keyboard_clear(vk_right)
keyboard_clear(vk_left)
keyboard_clear(vk_up)
keyboard_clear(vk_down)*/

var act_01 = keyboard_check_pressed(ord( global.act[|0] )) //current_weapon_1 simple atk
var act_02 = keyboard_check_pressed(ord( global.act[|1] )) //current_weapon_1 sk1
var act_03 = keyboard_check_pressed(ord( global.act[|2] )) //current_weapon_1 sk2
var act_04 = keyboard_check_pressed(ord( global.act[|3] )) //current_weapon_1 sk2

var act_10 = keyboard_check_pressed(ord( global.act[|4] )) //current_weapon_2 simple atk
var act_11 = keyboard_check_pressed(ord( global.act[|5] )) //current_weapon_2 sk1
var act_12 = keyboard_check_pressed(ord( global.act[|6] )) //current_weapon_2 sk2
var act_13 = keyboard_check_pressed(ord( global.act[|7] )) //current_weapon_2 sk2




if(current_action == "AIM")
{
    image_index = image_number -1
    charged_power = clamp( charged_power + charged_step,0,charged_powermax)
    target = battle_hero_get_nearest_target_in_zone()
    angle = 0
    
    if( act_01 or act_02 or act_03 or act_10 or act_11 or act_12 or act_04 or act_13  )
    {
        if(instance_exists(target) == false)
        {
            current_action ="IDLE"
            battle_hero_update_anim()
            alarm[current_slot] = current_slot_cooldown
            target = noone
        }
        else
        {
            switch(current_direction)
            {
                case "Right":  offx=10;offy=0; break;
                case "Left" :  offx=-10;offy=0; break;
                case "Up"   :  offx=0;offy=-10; break;
                case "Down" :  offx=0;offy=10; break;
            }
        
            p = instance_create(x + offx,y + offy,obj_projectile)
            p.atk = ceil(battle_hero_dmg_calculation() * (1 + charged_power/100))
            p.speed = 25
            p.direction = point_direction(p.x,p.y,target.x,target.y)
            p.image_angle = p.direction
            p.sprite_index = spr_arrow
            p.rotating = false
            p.source = id
            p.boomerang= false
            p.boomerang_max = 0
            p.dmgtype = current_dmgtype
            
        
            current_action ="IDLE"
            battle_hero_update_anim()
            alarm[current_slot] = current_slot_cooldown
            system_consume_ap(self.id, current_slot_ap)
            target = noone
        }
    }
    
    
    
}
else
{


    if(act_01)
    {
            current_slot = 0
            if(alarm[current_slot] <= 0)
            {
                if( actions_atk[current_slot, ACT_ID] != noone)
                {
                    
                    battle_set_currentslot_values(0,false)
                    
                    if( fstat[S_AP] >= current_slot_ap)
                    {
                       battle_set_currentslot_values(1,true)
                    }
                    else
                    {
                        system_create_info(x,y,"need AP",c_red,true,false)
                    }
                }
            }
    }
    
    if(act_02)
    {
            current_slot = 1
            if(alarm[current_slot] <= 0  )
            {
                if( actions_atk[current_slot, ACT_ID] != noone)
                {
                    battle_set_currentslot_values(0,false)
                    
                    if( fstat[S_AP] >= current_slot_ap)
                    {
                        battle_set_currentslot_values(1,false)
                    }
                    else
                    {
                        system_create_info(x,y,"need AP",c_red,true,false)
                    }
                }
            }
            //battle_hero_update_anim()
    }
    
    if(act_03)
    {
            current_slot = 2
            if(alarm[current_slot] <= 0 )
            {
                if( actions_atk[current_slot, ACT_ID] != noone)
                {
                    battle_set_currentslot_values(0,false)
                    
                    if( fstat[S_AP] >= current_slot_ap)
                    {
                        battle_set_currentslot_values(1,false)
                    }
                    else
                    {
                        system_create_info(x,y,"need AP",c_red,true,false)
                    }
                }
            }
            //battle_hero_update_anim()
    }
    
    if(act_04)
    {
            current_slot = 3
            if(alarm[current_slot] <= 0 )
            {
                if( actions_atk[current_slot, ACT_ID] != noone)
                {
                    battle_set_currentslot_values(0,false)
                    
                    if( fstat[S_AP] >= current_slot_ap)
                    {
                        battle_set_currentslot_values(1,false)
                    }
                    else
                    {
                        system_create_info(x,y,"need AP",c_red,true,false)
                    }
                }
            }
            //battle_hero_update_anim()
    }
    
    if(act_10)
    {
            current_slot = 4
            if(alarm[current_slot] <= 0 )
            {
                if( actions_atk[current_slot, ACT_ID] != noone)
                {
                    
                    battle_set_currentslot_values(0,false)
                    
                    
                    if( fstat[S_AP] >= current_slot_ap)
                    {
                         battle_set_currentslot_values(1,true)
                        
                    }
                    else
                    {
                        system_create_info(x,y,"need AP",c_red,true,false)
                    }
                }
            }
            //battle_hero_update_anim()
    }
    
    if(act_11)
    {
            current_slot = 5
            if(alarm[current_slot] <= 0 )
            {
                if( actions_atk[current_slot, ACT_ID] != noone)
                {
                    
                    battle_set_currentslot_values(0,false)
                    
                    
                    if( fstat[S_AP] >= current_slot_ap)
                    {
                         battle_set_currentslot_values(1,false)
                        
                    }
                    else
                    {
                        system_create_info(x,y,"need AP",c_red,true,false)
                    }
                }
            }
            //battle_hero_update_anim()
    }

}

if(act_01 == false and act_02 == false and act_03 == false and act_10 == false)
{
    stop = false

    if(up and stop == false)
    {
        show_debug_message("uppp")
        stop = true
        current_action = "MOVE"
        current_direction = "Up"
        battle_hero_update_anim()
        hero_move_to(current_direction)
    }
    
    
    if(down and stop == false)
    {
        show_debug_message("downnn")
        stop = true
        current_action = "MOVE"
        current_direction = "Down"
        battle_hero_update_anim()
        hero_move_to(current_direction)
    }

    if(right and stop == false)
    {
        show_debug_message("righhhhht")
        stop = true
        current_action = "MOVE"
        current_direction = "Right"
        battle_hero_update_anim()
        hero_move_to(current_direction)
    }
    
    if(left and stop == false)
    {
        show_debug_message("leeeeft")
        stop = true
        current_action = "MOVE"
        current_direction = "Left"
        battle_hero_update_anim()
        hero_move_to(current_direction)
    }

}
tried to fix thing with stop == false in condition (while adding stop = true in each moving part of code) but didnot change a thing !
Bug reproduced on computer (windows) testing so not really related to android. (but while arrows i donot have the problem at all)
 
Top