PLEASE HELP!

So wrote this code with the help of a video

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

system.actvate( “multitouch” )

physics.setDrawMode(“debug”)

display.setStatusBar( display.HiddenStatusBar )

physics.setGravity(0, 4.9)

local background = display.newImage(“nuclear_iphone_wallpapers.jpg”)

local can = display.newImage(“can.png”)
can.x = display.contentWidth/2
physics.addBody(can {bounce = 0.5, friction = 1.0})

local can2 = display.newImage(“can.png”)
can2.x = can.x - 105
physics.addBody(can2 {bounce = 0.5, friction = 1.0})

local can3 = display.newImage(“can.png”)
can3.x = can.x +105
physics.addBody(can3 {bounce = 0.6, friction = 1.0})

local leftWall = display.newRect(0, 0, 1, display.contentHeight )
local rightWall = display.newRect(display.contentWidth, 0, 1, display.contentHeight )
local ceiling = display.newrect(0, 0, display.contentWidth, 1 )

physics.addbody(leftWall, “static”, { bounce = 0.1} )
physics.addbody(rightWall, “static”, { bounce = 0.1} )
physics.addbody(ceiling, “static”, { bounce = 0.1} )

local floor = display.newImage(“floor.png”)
floor.y = display.contentHeight - floor.stageHeight/2
physics.addBody(floor, “static”, { bounce = 0.2, friction = 1.0})

function moveCan(event)
local can = event.target
can:applyLinearImpulse( 0, -0.2, event.x, event.y )
end

can:addEventListener(“touch”, moveCan)
can2:addEventListener(“touch”, moveCan)
can3:addEventListener(“touch”, moveCan)

After this it wouldnt run and i got these errors in the corona terminal

2011-01-18 18:31:03.185 Corona Simulator[646:903] Got error in FileWatch lastTimeModification

this keeps happening repeatedly then it stops

Can anyone please help??

i am using trial version of corona and i also have xcode [import]uid: 17040 topic_id: 5218 reply_id: 305218[/import]

You have a couple of errors there. I’ll list them, so you can correct the code. First I’ll put your line in, and second I’ll put the corrected line, so you can see the difference.

physics.addBody(can {bounce = 0.5, friction = 1.0}) -- you forgot a  
 -- comma here, between the target (can) and  
 -- the parameters table (valid for all your  
 -- "physics.addBody" commands)  
physics.addBody(can, {bounce = 0.5, friction = 1.0})  
  
local ceiling = display.newrect(0, 0, display.contentWidth, 1 ) --newRect  
local ceiling = display.newRect(0, 0, display.contentWidth, 1 )  
  
floor.stageHeight -- I'm not sure this exists... Also,  
 -- take note that the "display.stageHeight" has  
 -- been deprecated. Use "display.contentHeight"  
 -- instead.  

You need to be more careful when writing code. The loss of a comma means disaster here. :slight_smile: Moreover, Lua is case sensitive.
Good luck! [import]uid: 13720 topic_id: 5218 reply_id: 17450[/import]

Alright so i fixed the two errors and the tutorial i followed did use the “floor.stageHeight”
but when i run it in the simulator i am getting a syntax error

“Syntax error: /Users/John/Desktop/main/main.lua:12: ‘=’ expected near ‘local’”

do you have any idea??
thanks

[import]uid: 17040 topic_id: 5218 reply_id: 17611[/import]

Off the top of my head, try to use a PNG image for your background, it may not work with JPGs. Need confirmation here.

But post your code here, exactly as you have it in the main.lua file, because your error is on line 12 and I’m not sure which one is that. And when you post the code, put it between “[blockcode][/blockcode]" and "[blockcode][/blockcode]” tags. [import]uid: 13720 topic_id: 5218 reply_id: 17639[/import]

local physics = require("physics")  
physics.start()  
  
system.actvate( "multitouch" )  
  
 --physics.setDrawMode("debug")  
  
display.setStatusBar( display.HiddenStatusBar )  
  
physics.setGravity  
  
local background = display.newImage("nuclear\_iphone\_wallpapers.png")  
  
local can = display.newImage("can.png")  
can.x = display.contentWidth/2  
physics.addBody(can, {bounce = 0.5, friction = 1.0})  
  
local can2 = display.newImage("can.png")  
can2.x = can.x - 105  
physics.addBody(can2, {bounce = 0.5, friction = 1.0})  
  
local can3 = display.newImage("can.png")  
can3.x = can.x +105  
physics.addBody(can3, {bounce = 0.6, friction = 1.0})  
  
local leftWall = display.newRect(0, 0, 1, display.contentHeight )  
local rightWall = display.newRect(display.contentWidth, 0, 1, display.contentHeight )  
local ceiling = display.newRect(0, 0, display.contentWidth, 1 )  
  
physics.addbody(leftWall, "static", { bounce = 0.1} )  
physics.addbody(rightWall, "static", { bounce = 0.1} )  
physics.addbody(ceiling, "static", { bounce = 0.1} )  
  
local floor = display.newImage("floor.png")  
floor.y = display.contentHeight - floor.stageHeight/2  
physics.addBody(floor, "static", { bounce = 0.2, friction = 1.0})  
  
button:addEventListener( "tap", button )  
  
function moveCan(event)  
 local can = event.target  
 can:applyLinearImpulse( 0, -0.2, event.x, event.y )  
  
end  
can:addEventListener("touch", moveCan)  
can2:addEventListener("touch", moveCan)  
can3:addEventListener("touch", moveCan)  

[import]uid: 17040 topic_id: 5218 reply_id: 17647[/import]

still gettin just a black screen when i run it in simulator
and a syntax error
[import]uid: 17040 topic_id: 5218 reply_id: 17649[/import]

system.actvate( “multitouch” ) --comment this out for now

physics.setGravity(0,0) – give it a x,y value to get rid of all the “=” issues

physics.addbody(leftWall, “static”, { bounce = 0.1} )
physics.addbody(rightWall, “static”, { bounce = 0.1} ) – I think addBody needs the uppercase B
physics.addbody(ceiling, “static”, { bounce = 0.1} )

There is other problems but this is my first day doing any sort of programming/ scripting.
so i can’t be of much help. I’m sure You’ll get there! [import]uid: 21698 topic_id: 5218 reply_id: 17684[/import]

thanks for the help [import]uid: 17040 topic_id: 5218 reply_id: 17686[/import]

now everything works except the cans wont respond to touch

heres the code

local physics = require("physics")  
physics.start()  
  
--system.actvate( "multitouch" )  
  
 --physics.setDrawMode("debug")  
  
display.setStatusBar( display.HiddenStatusBar )  
  
physics.setGravity( 0, 9.8 )  
  
local background = display.newImage("nuclear\_iphone\_wallpapers.png")  
  
local can = display.newImage("can.png")  
can.x = display.contentWidth/2  
physics.addBody(can, {bounce = 0.6, friction = 1.0})  
  
local can2 = display.newImage("can.png")  
can2.x = can.x - 105  
physics.addBody(can2, {bounce = 0.6, friction = 1.0})  
  
local can3 = display.newImage("can.png")  
can3.x = can.x +105  
physics.addBody(can3, {bounce = 0.6, friction = 1.0})  
  
local leftWall = display.newRect(0, 0, 1, display.contentHeight )  
local rightWall = display.newRect(display.contentWidth, 0, 1, display.contentHeight )  
local ceiling = display.newRect(0, 0, display.contentWidth, 1 )  
  
physics.addBody(leftWall, "static", { bounce = 0.1} )  
physics.addBody(rightWall, "static", { bounce = 0.1} )  
physics.addBody(ceiling, "static", { bounce = 0.1} )  
  
local floor = display.newImage("floor.png")  
floor.y = display.contentHeight - floor.stageHeight/2  
  
physics.addBody(floor, "static", { bounce = 0.2, friction = 1.0})  
  
button:addEventListener( "tap", button )  
  
function moveCan(event)  
 local can = event.target  
 can:applyLinearImpulse( 0, -0.2, can.x, can.y )  
end  
  
can:addEventListener("touch" , moveCan)  
can2:addEventListener("touch" , moveCan2)  
can3:addEventListener("touch" , moveCan3)  

any ideas? [import]uid: 17040 topic_id: 5218 reply_id: 17845[/import]

The last two lines refer to functions moveCan2 and moveCan3, but those functions don’t exist. [import]uid: 12108 topic_id: 5218 reply_id: 17848[/import]

does anyone know how to code a timer that counts up from zero and stops when one of the cans hits the floor??? [import]uid: 17040 topic_id: 5218 reply_id: 18127[/import]