I believe I have painted myself into a corner here, but if you take an image which is the same size as the screen, call it “crate.png” and use this in your main.lua:
[lua]local img = display.newImage( “crate.png” )
local blob = nil
function img:timer( event )
– img.rotation = img.rotation + 1
end
function img:touch( event )
–if (event.phase == “ended”) then
if (blob == nil) then
blob = display.newCircle( event.x, event.y, 25 )
blob:setFillColor( 0,0,255,150 )
blob:setStrokeColor( 255,0,0,150 )
blob.strokeWidth = 4
end
blob.x, blob.y = event.x, event.y
–img.xReference, img.yReference = event.x - img.x, event.y - img.y
–img.xReference, img.yReference = event.x - img.xOrigin, event.y - img.yOrigin
img.xReference, img.yReference = event.x, event.y
–img.xOrigin, img.yOrigin = event.x, event.y
print(event.x, event.y, img.x, img.y, img.xOrigin, img.yOrigin, img.xReference, img.yReference)
–[[
x,y is effectively the origin plus the reference
origin is the centre relative to the parent
reference is relative to the origin
]]–
–end
return true
end
Runtime:addEventListener( “touch”, img )
timer.performWithDelay( 200, img, 0 )[/lua]
You will see that moving the touch point around the screen alters the event x,y and img reference x,y that it also modifies the img x,y - but not the img origin x,y.
You’ll notice that the image stays in the centre of the screen.
As I understand it, the reference point (according to the docs: http://developer.anscamobile.com/content/display-objects#object.xReference) should not move the image, but it does effectively change the img x,y values.
Can someone explain this, please? Is my understanding or the docs which are incorrect or incomplete?
Thanks,
Matt. [import]uid: 8271 topic_id: 4647 reply_id: 304647[/import]