I'm using the most recent version. I'm running it in the editor because I don't have solarus_run on my mac, just the GUI.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Pages1
#2
Development / Mac keyboard controls?
February 22, 2016, 09:45:24 PM
Hi, I'm making a game with a group of people for a class we're all in. I have a macbook pro and a desktop computer. My groupmate also has a linux laptop, and on windows and linux the keyboard controls work. However, for a mac, it never goes into on_key_pressed. I cannot figure out why this is the case, can anyone help me? This is what we have:
Code ( lua) Select
function game_manager:start_game()
...
game:set_command_keyboard_binding("left", "a")
game:set_command_keyboard_binding("right", dvorak and "e" or "d")
game:set_command_keyboard_binding("up", dvorak and "," or "w")
game:set_command_keyboard_binding("down", dvorak and "o" or "s")
game:set_command_keyboard_binding("pause", "escape")
....
end
function sol.main:on_key_pressed(key, modifiers)
print("hey")
print(key)
if game:is_paused() or game:is_suspended() or hero.entitydata == nil then
print("PAUSED!")
return
end
mousex, mousey = sol.input.get_mouse_position()
x, y = convert_to_map(mousex, mousey)
if x ~= nil then
hero:set_direction(hero:get_direction4_to(x, y))
end
hero = game:get_hero()
if hero:get_state() ~= "freezed" then
if key == "space" then
hero.entitydata:startability("sword")
elseif (key == "e" and not dvorak) or (key == "." and dvorak) then
hero.entitydata:startability("swordtransform")
elseif key == "left shift" then
hero.entitydata:startability("block")
elseif key == "escape" then
print("TODO: pause menu")
--debug keys
elseif key == "r" then
hero.entitydata:throwrandom()
elseif key == "k" then
hero.entitydata:kill()
end
end
end
Pages1