Hello im newbie to the corona i want to ask why my object jump directly to cordinate’s, i want to walk to there not instantly change his to new x and y.
display.setStatusBar( display.HiddenStatusBar ) local physics = require "physics" physics.start() physics.setGravity( 0, 0 ) system.setAccelerometerInterval( 10 ) local menuItems local background local playBtn local destx local desty local obj --Main-- function main() --Methods-- mainMenu() end function mainMenu() menuItems = display.newGroup() background = display.newImage( "bg.png" ) playBtn = display.newImage( "playbtn.png" ) playBtn.name = "playbutton" playBtn.x, playBtn.y = display.contentWidth / 2 + 40, display.contentHeight / 2 menuItems:insert( background ) menuItems:insert( playBtn ) playBtn:addEventListener( "tap", loadGame ) end function loadGame(event) if event.target.name == "playbutton" then transition.to(menuItems,{time = 210, alpha=0, onComplete = addGameScreen}) playBtn:removeEventListener( "tap", loadGame ) end end function addGameScreen() demoLevel() end function demoLevel() background = display.newRect( 0, 0, display.contentWidth + 120, display.contentHeight ) background:setFillColor ( 255, 255, 255 ) obj = display.newImage("rect.PNG") obj.x, obj.y = 32, 32 physics.addBody( obj, { density=3.0, friction=0.5} ); Runtime:addEventListener ( "enterFrame", move ) Runtime:addEventListener ( "tap", onTap ) end function move( ) if destx ~= nil then obj.x = obj.x + destx - obj.x end if desty ~= nil then obj.y = obj.y + desty - obj.y end end function onTap( event ) destx = event.x desty = event.y print("".. destx - obj.x .. " " .. obj.y - desty .."") end main()
I want to ask about structure of code too
