Make blocks collide

I have a game where I am trying to make some blocks collide into each other. Right now they fall on the floor and bounce around but they won’t touch each other. What code do I need to do this? Also I have code that let’s me drag one of the blocks but when I pasted it under under block it would not work. It just blacked my screen out. Any help would be greatly appreciated. [import]uid: 72372 topic_id: 12116 reply_id: 312116[/import]

I highly doubt you will get any answer without posting your code. [import]uid: 48521 topic_id: 12116 reply_id: 44112[/import]

Here is my code

module(…, package.seeall)

function new()
local localGroup = display.newGroup()



local physics = require(“physics”)
physics.start()

local background = display.newImage (“title2.png”)
background.x = 240
–> This sets the background

local instructions = display.newImage (“instructions.png”)
instructions.x = 100
instructions.y = 240
instructions.xScale = .5
instructions.yScale = .5

local highscores = display.newImage (“highscores.png”)
highscores.x = 380
highscores.y = 240
highscores.xScale = .5
highscores.yScale = .5

local floor = display.newImage(“floor.png”)
floor.x = 230
floor.y = 360

physics.addBody( floor, “static”, { friction=0.5, bounce=0.3 } )

local redblock = display.newImage( “redblock.png” )
redblock.x = 180
redblock.y = 50
redblock.rotation = 10
redblock.xScale = .5
redblock.yScale = .5

physics.addBody( redblock, { density=2.0, friction=0.5, bounce=0.5 } )

local redblock = display.newImage( “redblock.png” )
redblock.x = 350
redblock.y = 50
redblock.rotation = 5
redblock.xScale = .5
redblock.yScale = .5

physics.addBody( redblock, { density=2.0, friction=0.5, bounce= 0.5 } )

end
[import]uid: 72372 topic_id: 12116 reply_id: 44160[/import]

always use lua tags to post code.

I couldn’t run the code without knowing size of your images, but I have a doubt that your scaling of the object is the culprit. Try removing scaling and then run the program and see what happens… [import]uid: 48521 topic_id: 12116 reply_id: 44163[/import]

chinmay.patel,

thank you so much for replying. I am obviously very new at this. i have only been playing with this a week now. So I removed the scaling and of course the blocks got bigger but they are touching more. So another question? When you said always use lua tags to post code. What does that mean?

Lastly to get the blocks as small as I want them how do I do that? What size should they be brought in? i’m assuming I choose that pixel size in photoshop when I save the file and bring it in that way correct?

How do I know what size to bring in any object actually. Sorry if this is so basic but I’m a serious newby :slight_smile: [import]uid: 72372 topic_id: 12116 reply_id: 44164[/import]