Hello I am working on a game but i have a floating object in the air and i want to keep it floating it has a transition.to on it but i also need it to be a sensor can you help me.
local function myTouchListener( event )
--displays x and y location on the console
print( “Touch X location”…event.x )
print( “Touch Y location”…event.y )
end
local myButton = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
myButton.anchorX = 0
myButton.anchorY = 0
myButton:setFillColor( 0, 0, 0 )
myButton:addEventListener( “touch”, myTouchListener )
–creats a white circle to have rings around
local whitec = display.newCircle( 153, 112, 40 )
whitec:setFillColor( 1,1,1 )
–creats a red circle to start with
local fball = display.newCircle( 157, 390, 15 )
fball:setFillColor( 1, 0.2, 0.2 )
–moves the red bal where you tap
local function myTouchListener( event )
local shoot = transition.to( fball, { time=250, x=(event.x) ,y=(event.y) } )
end
local shooter = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
shooter.anchorX = 0
shooter.anchorY = 0
shooter:setFillColor( 0, 0, 0 )
shooter:addEventListener( “touch”, myTouchListener )
– makes a red blue and yellow ring
local rring = display.newImageRect( “images/red-ring.png”, 86, 97 )
rring.x = 114
rring.y = 88
local bring = display.newImageRect( “images/blue-ring.png”, 86, 120 )
bring.x = 200
bring.y = 100
local yring = display.newImageRect(“images/yellow-ring.png”, 135, 57 )
yring.x = 146
yring.y = 158
– rotates the rings
local function listener( event )
local bluem = transition.to( bring, {time=2500, x=(bring.x-84), y=(bring.y+32) ,rotation = 170 } )
local redm = transition.to( rring, { time=2500, x=(rring.x+83), y=(rring.y+37) ,rotation = -195 } )
local yellowm = transition.to( yring, { time=2500, x=(yring.x+0), y=(yring.y-88), rotation = 165 } )
end
timer.performWithDelay( 2000, listener )
–creats all the sencors that i will need for my game