I a very new to Corona. What I am trying to do is make a tile game where you slide the tiles around to get them in order. I have all the tiles boxed by borders however when the tile hits the border it moves away. How do I get it to not move on a tile touching it? Thanks [import]uid: 14704 topic_id: 6267 reply_id: 306267[/import]
I’m no professional but I do this to keep my physics bodies from moving.
physics.addBody( yourtile, "static", { stuff } )
The “static” part is what keeps it in place. [import]uid: 20207 topic_id: 6267 reply_id: 21601[/import]
I tried that,exactly as you typed, and the border still moves instead of containing the tiles. Here is the code that I have for the border:
[lua]borderBodyElement = { density = 10, friction=5, bounce = 0, bodyType=“static” }
local borderTop=display.newRect( 25,40,270,5 )
borderTop:setFillColor( 248,248,255 ) – make invisible
physics.addBody( borderTop, borderBodyElement )
borderTop.isFixedRotation = true[/lua]
Not sure what I am doing wrong. Thanks for any help!
[import]uid: 14704 topic_id: 6267 reply_id: 21610[/import]
You said you tried it like I typed it, but your code shows “static” outside of the ‘physics.addBody’.
Did you try it inside before?
This is a line of code I am using and it interacts with other physics bodies perfectly without moving.
physics.addBody( ground, "static", { friction=0.5, bounce=0.3 } )
I tinkered with it a little and this seems to work. Dropping balls on it doesn’t move it.
local borderTop = display.newRect( 25,40,270,5 )
borderTop:setFillColor( 255,255,255,0 ) -- make invisible
physics.addBody( borderTop, "static", {density = 10, friction=5, bounce = 0} )
borderTop.isFixedRotation = true [import]uid: 20207 topic_id: 6267 reply_id: 21613[/import]
I had tried it like you had stated and it hadn’t worked…however, having just retried it it now is working (gotta love it). Any idea how to keep the tile from sliding over the border if pulled too far? Again thanks. [import]uid: 14704 topic_id: 6267 reply_id: 21616[/import]
I’m not exactly certain how to prevent that. Maybe this video will help.
http://www.youtube.com/watch?v=LoUisojkcGE [import]uid: 20207 topic_id: 6267 reply_id: 21628[/import]
“Any idea how to keep the tile from sliding over the border if pulled too far?”
Making the border thicker usually helps. You can go a lot thicker. [import]uid: 13859 topic_id: 6267 reply_id: 21634[/import]