Hi Guys,
I have read the physics 101 but there has to be a bit missing, it doesn’t show the line where it adds the img to the circle…
Please help!! @Simeon
Thanks
Lee
Hi Guys,
I have read the physics 101 but there has to be a bit missing, it doesn’t show the line where it adds the img to the circle…
Please help!! @Simeon
Thanks
Lee
any help @Anyone lol
@Simeon please help
.@Chezzy - have a look at the MineSweeper code at: https://www.dropbox.com/sh/pdl4dqw0ng0l49c/O04VVbVi2G
In the menu screen I attach a mine sprite to the physics object.
You can see what it looks like here: http://twolivesleft.com/Codea/Talk/discussion/1438/minesweeper-version-for-the-app-store#Item_17
.@Chezzy - I extended the PhysicsDebugDraw() class which comes with the Physics Demo in Codea. You can download the modified class from here: https://www.dropbox.com/s/4d8lks9k0fi2wno/PhysicsDebugDraw.lua
I attached the image to the Circle object because my sprite was round. When you create the circle, make it the same size as your sprite. I modified the PhysicsDebugDraw:draw() function so that if an image had been set (i.e. spriteImage was not nil), it draws that sprite instead of a circle. You should be able to do something similar for what you need.
In your main you need to assign the sprite by doing something like:
function setup()
img = readImage("Your Image")
physicsDraw = PhysicsDebugDraw()
physicsDraw.spriteImage = img
-- You can then create some objects
defaultGravity = physics.gravity()
createGround()
createBox(WIDTH/2, 100, 30, 30)
createCircle(WIDTH/2 + 50, HEIGHT, 30)
createRandPoly(WIDTH/2 + 150, 120)
end
function draw()
physicsDraw:draw()
end
-- The next function is optional. Use it if you want to see the collision points
function collide(contact)
physicsDraw:collide(contact)
end