Hi all,
I'm trying to make a small menu that can be toggled when the P key is pressed. The below code does create the sprite however when the Key P is pressed, it is not moved to the coordinates that it should be.
If I set the starting position of the sprite to 50,50, instead of 200,200, the sprite starts in the center of the screen, if I then press the P key, it disappears.
p_key_pressed = 0
character_panel_Icon = 0
character_panel_Sprite = 0
function character_panel_init(e)
character_panel_Icon = LoadImage ( "scriptbank\\xanthir\\char_panel.png" )
character_panel_Sprite = CreateSprite ( character_panel_Icon )
SetSpritePosition (character_panel_Sprite,200,200)
end
function character_panel_main(e)
Prompt("p _key_pressed: " .. p_key_pressed .. " InKey: " .. g_InKey)
--if p_key_pressed == 0 and g_InKey == "p" or g_InKey == "P" then
if p_key_pressed == 0 and release_key == false then
p_key_pressed = 1
SetSpritePosition (character_panel_Sprite,25,25)
end
--if p_key_pressed == 1 and g_InKey == "p" or g_InKey == "P" then
if p_key_pressed == 1 and release_key == true then
p_key_pressed = 0
SetSpritePosition (character_panel_Sprite,200,200)
end
end
function release_key(e)
if g_InKey ~= "p" and g_InKey ~= "P" then
p_key_pressed = 0
return true
else
return false
end
end
Any help with this would be hugely appreciated, it's driving me crazy