hey guys,
i watched a tutorial on dragging physics. well im wanting to get the cursor i have to be draggable. the one in the video uses the sample dragMe which is the roundedrect, but im using an image. any ideas? thanks in advance!
[code]
module(…, package.seeall)
local localGroup
function new()
localGroup = display.newGroup()
print( “Level 1” )
local sky = display.newImage( “Turqouise Back.png”, 0, 0 )
localGroup:insert(sky)
local button = display.newImage( “Main Menu.png” )
local function buttont ( event )
media.playEventSound( “Robot Blip.caf” )
if event.phase == “ended” then
director:changeScene(“Menu”,“moveFromLeft”)
end
end
button:addEventListener(“touch”,buttont)
button.x = 260
button.y = 34
localGroup:insert(button)
local cursor = display.newImage( “triangle.png”, 120, 450 )
localGroup:insert(cursor)
[code] [import]uid: 19836 topic_id: 7520 reply_id: 307520[/import]
i added the code to start the physics engine, but still can’t figure it out. any help would be greatly appreciated! [import]uid: 19836 topic_id: 7520 reply_id: 26798[/import]
I am not an expert on this. Prior issues I replaced newImage with new ImageRect. Worked wonders for me. Try it? [import]uid: 8576 topic_id: 7520 reply_id: 26918[/import]
thanks but it didn’t work out. any other things i may be doing wrong? [import]uid: 19836 topic_id: 7520 reply_id: 27492[/import]
is my code wrong, or do i just not have a certain code in there? [import]uid: 19836 topic_id: 7520 reply_id: 27542[/import]
please any help? i just need to figure this out and then im good to go. [import]uid: 19836 topic_id: 7520 reply_id: 27591[/import]
i added a few more lines of code, but it still doesn’t work. any ideas?
[code]
local physics = require(“physics”)
physics.start()
physics.setGravity(0, 0)
–delete setdrawmode when done with adding all the physics…
physics.setDrawMode(“hybrid”)
module(…, package.seeall)
local localGroup
function new()
localGroup = display.newGroup()
print( “Level 1” )
local sky = display.newImage( “Turqouise Back.png”, 0, 0 )
localGroup:insert(sky)
local button = display.newImage( “Main Menu.png” )
local function buttont ( event )
media.playEventSound( “Robot Blip.caf” )
if event.phase == “ended” then
director:changeScene(“Menu”,“moveFromLeft”)
end
end
button:addEventListener(“touch”,buttont)
button.x = 260
button.y = 34
localGroup:insert(button)
local triangle = display.newImage( “triangle.png” )
object:setDrag
myImage:setDrag{ drag=true, limitX=false, limitY=false, onPress=myPressFunction,onDrag=myDragFunction, onRelease=myReleaseFunction, bounds={ 10, 10, 200, 50 })
localGroup:insert(triangle)
[code] [import]uid: 19836 topic_id: 7520 reply_id: 27647[/import]
please anything? [import]uid: 19836 topic_id: 7520 reply_id: 27877[/import]
I am not sure if the setDrag applies to images? If I follow the documentation correctly it does not (applies to movieClip)?
Also Your code should not read object:setDrag but triangle:setDrag. [import]uid: 8576 topic_id: 7520 reply_id: 27885[/import]
http://developer.anscamobile.com/code/modified-moviecliplua
http://blog.anscamobile.com/2010/06/improved-movieclip-library/
myAnim:setDrag{
drag=true,
limitX=false,
limitY=false,
onPress=myPressFunction,
onDrag=myDragFunction,
onRelease=myReleaseFunction,
bounds={ 10, 10, 200, 50 }
}
[import]uid: 24111 topic_id: 7520 reply_id: 27897[/import]
okay thanks guys. i got it. [import]uid: 19836 topic_id: 7520 reply_id: 27970[/import]