Omnimaga
Calculator Community => TI Calculators => Lua => Topic started by: Augs on September 04, 2012, 11:04:26 am
-
The code is:
platform.apilevel = '1.0'
Person = image.new("\012\000\000\000\024\000\000\000\000\000\000\000\024\000\000\000\016\000\001\000\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128 \225\160\253 \225\160\253 \225\160\253 \225\160\253 \225\160\253\000\128\000\128\160\253 \225\160\253 \225\160\253 \225\160\253 \225\160\253 \225\000\128\000\128 \225\160\253 \225\160\253 \225\160\253 \225\160\253 \225\160\253\000\128\000\128\160\253\000\128\160\253\000\128\000\128\000\128\000\128 \225\000\128 \225\000\128\000\128\000\128\208\254\000\128\208\254\208\254\208\254\208\254\000\128\208\254\000\128\000\128\000\128\208\254\208\254\208\254\000\128\208\254\208\254\000\128\208\254\208\254\208\254\000\128\000\128\208\254\208\254\208\254\000\128\208\254\208\254\000\128\208\254\208\254\208\254\000\128\000\128\208\254\208\254\208\254\208\254\208\254\208\254\208\254\208\254\208\254\208\254\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\224\145\224\145\224\145\224\145\224\145\224\145\224\145\224\145\224\145\224\145\000\128\000\128\224\145\224\145\000\128\224\145\224\145\224\145\224\145\000\128\224\145\224\145\000\128\000\128\224\145\224\145\000\128\224\145\224\145\224\145\224\145\000\128\224\145\224\145\000\128\000\128\224\145\224\145\000\128\224\145\224\145\224\145\224\145\000\128\224\145\224\145\000\128\000\128\000\128\000\128\000\128\224\145\224\145\224\145\224\145\000\128\000\128\000\128\000\128\000\128\208\254\208\254\000\128\224\145\224\145\224\145\224\145\000\128\208\254\208\254\000\128\000\128\208\254\208\254\000\128\224\145\224\145\224\145\224\145\000\128\208\254\208\254\000\128\000\128\000\128\000\128\000\128\224\145\000\128\000\128\224\145\000\128\000\128\000\128\000\128\255\255\255\255\000\128O\128O\128\000\128\000\128O\128O\128\000\128\255\127\255\127\255\255\255\255\000\128O\128O\128\000\128\000\128O\128O\128\000\128\255\127\255\127\000\128\000\128\000\128\000\128O\128\000\128\000\128O\128\000\128\000\128\000\128\000\128\000\128\000\188\000\188\000\188\000\188\000\128\000\128\000\188\000\188\000\188\000\188\000\128\000\128\000\188\000\188\000\188\000\188\000\128\000\128\000\188\000\188\000\188\000\188\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128\000\128")
x = 1
y = 1
function on.arrowUp()
y = y-1
end
function on.arrowDown()
y = y+1
end
function on.arrowRight()
x = x+1
end
function on.arrowLeft()
x = x+1
end
function on.timer()
platform.window:invalidate()
end
function on.paint(gc)
gc:drawImage(Person, x, y)
platform.window:invalidate()
end
The person won't move until I click the middle of the screen. The program works fine on the PC. I am running on 3.1 and using 3.2 pc software. Any ideas on why it won't work?
-
The reason is simple :
- On the computer, everytime you *do* something ( move the mouse, etc. ), the screen gets refreshed.
- On the handheld, platform.window:invalidate() has to be called. You wanted that by calling it in [lua]on.timer[/lua], but you forgot to do [lua]timer.start[/lua](0.01) to actually start the timer.
Instead of doing that, you could simply put the invalidate at the end of the arrow functions. (Btw, you can also use [lua]on.arrowKey[/lua](arrow) (arrow=="left" etc.)
Also, don't put platform.window:invalidate() inside of on.paint, it's useless.
-
The reason is simple :
- On the computer, everytime you *do* something ( move the mouse, etc. ), the screen gets refreshed.
- On the handheld, platform.window:invalidate() has to be called. You wanted that by calling it in [lua]on.timer[/lua], but you forgot to do [lua]timer.start[/lua](0.01) to actually start the timer.
Instead of doing that, you could simply put the invalidate at the end of the arrow functions. (Btw, you can also use [lua]on.arrowKey[/lua](arrow) (arrow=="left" etc.)
Also, don't put platform.window:invalidate() inside of on.paint, it's useless.
Why thanks, as you know I am new to this. Since you introduced me last night.
Thanks, it worked.
-
np.
So did you make it work ? :)
-
np.
So did you make it work ? :)
Yes, This is one of many problems I will have during the making of my rpg