lua - Corona SDK - frame-by-frame animation and accelerometer problem -


we doing game moving objects around frame-by-frame , using accelerometer.

we have hooked on 2 events - drawing frame , acc.

the problem is, after receive acc event, put x value in variable.

then use variable move object on screen, there considerable slow down. ( turn phone, , after second object moving properly, second way game, expect immediate response).

what doing wrong? there workaround this, or can give params accelerometer?

unfortunately serious problem - real blocker. if not work, have find solution (not corona) implementing game.

thanks in advance!!! danail

ps: here's source:

local lastxgravity = 0  local function move(event)          eventtime=event.time         elapsedtime = eventtime - lastdrawtime         lastdrawtime = eventtime          xspeed = lastxgravity         local xmoved = xspeed * elapsedtime         object.x= object.x + xmoved end  function acc(event)            lastxgravity = event.xgravity end  runtime:addeventlistener("accelerometer", acc) runtime:addeventlistener( "enterframe", move ) 

i don't know corona development, there general issues. first gravity containing? gravity vector or total acceleration = gravity + useracceleration? need useracceleration = totalacceleration - gravity or member event providing directly, otherwise there no chance.

if have user acceleration, need integrate twice position. see equations of motion. in case code like:

velocity = useracceleration * elapsedtime

position = 0.5*useracceleration * elapsedtime^2

in general precise position detection accelerometer , gyroscope still unresolved problem, don't expect precise results. if interested in evaluating there impulse in 1 direction, might work. see example getting displacement accelerometer data core motion


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -