- Code: Select all
if (key == "shift" and key == "w") then
sound.play2DSound( runsound_ID );
anim.setSpeed(obj, "Walk", 2.8);
end
if (key == "shift" and key == "w") then
sound.play2DSound( runsound_ID );
anim.setSpeed(obj, "Walk", 2.8);
end
if (key == "w" and input.keyDown("shift")==1)) then
if (string.find("ijkluo",key) > 0 and not key == "") then
sky.lprint("DEBUG: moveObj");
sky.lprint("DEBUG: shift: "..input.keyDown("shift"));
if (input.keyDown("shift") == 1) then
d = d/20;
end
if (key == "i") then
x,y,z = entity.getPosition(eid); -- eid=0 -> crash
y = y+d;
entity.setPosition(eid,x,y,z);
elseif (key == "j") then
.....
end
end
if (key == "0") then
if (input.keyDown("shift")==1) then
sky.lprint("THIS IS UNREACHABLE");
end
end
sky.lprint("DEBUG: keyPressed("..key..")");
if (key == "" and input.keyDown("shift")==1 and input.keyDown("0")==1) then
isShiftPressed = false;
function onKeyDown( key )
if(key == "shift")then isShiftPressed = true; end
if(key == "w" and isShiftPressed) then
-- set the run speed
end
end
function onKeyUp( key )
if(key == "shift")then isShiftPressed = false; end
end
Which is why movement we tend to handle in the update loop to adapt the speeds on the keys pressed.
Users browsing this forum: No registered users and 3 guests