Pihas
Joined: 25 Oct 2008 Posts: 60 Location: Lithuania
|
Posted: Sat Oct 25, 2008 10:29 pm Post subject: Need help on LuaPlayerHMv2 final beta with analog |
|
|
hi, all i'm not new at programing in lua language but having problems on LuaPlayerHMv2 final beta can't uderstand how to use analog on this version, i tried a lot of different ways, but it doesn't work :/ , i too tried to convert old scripts to new one but same broblems...
Thats my project, so i converted bigest part of scripts to new lua player engine but having problems with mouse :(
That's on what i'm working:
(Don't follow link on image it's lithuanian website...)
Code: |
red = Color.new(255,0,0,0)
black = Color.new(0,0,0,0)
white = Color.new(255,255,255,255)
--creates player
player = Image.createEmpty(32,32)
player:clear(Color.new(255,0,0,0))
--Players table
Player = { x = 100, y = 100, img = player }
--functiion for analog movement
function analogMove()
pad = Controls.read()
anaX = pad:analogX()
anaY = pad:analogY()
-- anaX and anaY represents number from -128 to 127
-- number "50" is analog deadzone
if anaX > 50 then
Player.x = Player.x + 5
end
if anaX < -50 then
Player.x = Player.x - 5
end
if anaY > 50 then
Player.y = Player.y + 5
end
if anaY < -50 then
Player.y = Player.y - 5
end
end
while true do
screen.clear(Color.new(0,0,0,0))
Image.blit(Player.x,Player.y,Player.img) <-- Here is my problem :cry:
analogMove()
-- prints X and Y analog coordinates
screen.print(5,5,"analogX: " .. anaX,12, white, white)
screen.print(5,15,"analogY: " .. anaY,12, white, white)
if pad:cross() then
break
end
screen.flipscreen()
screen.waitVblankStart()
end |
|
|