I inserted a triangle image and gave it dimensions. But when i drag the dimensions, i’m able to drag the image by clicking next to that image. Here is my code…
[lua]------------
–TRIANGLE–
local triangle = display.newImage(“triangle.png”)
triangle.x = 100
triangle.y = 100
triangleShape = { 5,-25, 57,50, -37,50 }
physics.addBody( triangle, “static”, { shape=triangleShape } )
–
– touch listener function
function triangle:touch( event )
if event.phase == “began” then
self.markX = self.x – store x location of object
self.markY = self.y – store y location of object
elseif event.phase == “moved” then
local x = (event.x - event.xStart) + self.markX
local y = (event.y - event.yStart) + self.markY
self.x, self.y = x, y – move object based on calculations above
end
return true
end
– make ‘myObject’ listen for touch events
triangle:addEventListener( “touch”, triangle )
[import]uid: 132369 topic_id: 33783 reply_id: 333783[/import]
[import]uid: 118379 topic_id: 33783 reply_id: 134360[/import]