Alright guys thanks for all the help, this will prob be my last question for now =P . But here is my main.lua that I have been following a tutorial on youtube. In this folder I have the picture of the floor, the background, the main.lua, and the picture of a dog. Here is the main.lua
–> Add physics engine, start up engine, and apply gravity
local physics = require(“physics”)
physics.start()
– Set gravity to act “down” (ie, towards the bottom of the device)
physics.setGravity( 0, 9.8 )
–> Hide status bar using setStatusBar()
display.setStatusBar(display.HiddenStatusBar)
system.activate( “multitouch” )
–> physics.setDrawMode(“hybrid”)
–> Add background image
local background = display.newImage(“space_background.jpg”)
–> Add dog to stage and position
local dog = display.newImage(“dog.png”)
dog.x = display.contentWidth/2
–> Turn dog into physics body
physics.addBody(dog, { bounce = 0.5, radius = 45, friction = 1.0} )
local dog2 = display.newImage(“dog.png”)
dog2.x = dog.x - 105
–> Turn dog2 into physics body
physics.addBody(dog2, {bounce=0.4, radius = 45, friction = 1.0})
local dog3 = display.newImage(“dog.png”)
dog3.x = dog.x + 105
–> Turn dog3 into physics body
physics.addBody(dog3, {bounce=0.5, radius = 45, friction = 1.0})
–> Add floor image and position
local floor = display.newImage(“floor.png”)
floor.y = display.contentHeight - floor.stageHeight/2
–> Turn floor into a physics body
physics.addBody(floor, “static”, { bounce = 0.2})
–Define wall graphics (rectangles)
local leftWall = display.newRect(0, 0, 1, display.contentHeight )
local rightWall = display.newRect(display.contentWidth, 0, 1, display. contentHeight )
– Turn wall graphics into physics bodies
physics.addBody(leftWall, “static”, { bounce = 0.1} )
physics.addBody(rightWall, “static”, { bounce = 0.1} )
– Define our touch event listener.
function moveDog(event)
local dog = event.target
dog:applyLinearImpulse( 0, -0.2, event.x, event.y )
end
– Add the listener to our dog
dog:addEventListener(“touch”, moveDog)
dog2:addEventListener(“touch”, moveDog)
dog3:addEventListener(“touch”, moveDog)
From all of that would it be possible to add the menu screen? And from the ghost vs. monster I see that his main.lua is very short but it includes like import director and I see director:changeScene( “loadmainmenu” ). Btw, I’m starting to read the book, I got from google books =P Thanks for the patients with all of my noby questions.
[import]uid: 14686 topic_id: 5116 reply_id: 17180[/import]