If anybody was wondering how to do the thing I was trying to accomplish heres a good example…
[lua]display.setStatusBar( display.HiddenStatusBar ) – HIDE STATUS BAR
local gameState = 0
local _W = display.contentWidth
local _H = display.contentHeight
local gBox = display.newRect(0,0,50,50)
gBox.x = math.random(150,200) ; gBox.y = math.random(150,350)
gBox:setFillColor(0,255,0)
local planet = display.newRect(0,0,50,50)
local function onTouch(event)
local t = event.target
local phase = event.phase
if “began” == event.phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true
gBox:setFillColor(255,0,0)
– Store initial position
t.x0 = event.x - t.x
t.y0 = event.y - t.y
elseif t.isFocus then
if “moved” == phase then
t.x = event.x - t.x0
t.y = event.y - t.y0
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
print(“YES!! Touching the gBox”)
end
end
– Stop further propagation of touch event!
return true
end
gBox:addEventListener(“touch”, onTouch)[/lua] [import]uid: 51459 topic_id: 17209 reply_id: 65083[/import]