Hello everyone, I am new to this AMAZING community and have been looking around to find my answer and this seems to be the place.
Theres actually a few things I’d like to learn how to do:
*Create a score function so when the user taps the ball they get a point but if the ball touches the ground the score resets
*Make an image I’ve created (Soccer ball) act like a soccer ball
*making a sound play (crowd cheering) every 20 points scored
I downloaded the source code from the 8 minute balloon game and have been messing with it and adding new things
Here’s what I have so far (Please don’t laugh this is my first time)
--\> Add physics engine, start up the engine, and apply gravity
local physics = require("physics")
physics.start()
physics.setGravity(0, 4.9)
system.activate( "multitouch" )
-- physics.setDrawMode("hybrid")
--\> Hide status bar
display.setStatusBar( display.HiddenStatusBar )
-- Create the bounds of the "arena"
local background = display.newImage("soccersky.png")
local floor = display.newRect(320, 0, 1, 480)
local lWall = display.newRect(0, 480, 320, 1)
local rWall = display.newRect(0, -1, 320, 1)
local ceiling = display.newRect(-1, 0, 1, 480)
staticMaterial = {density=2, friction=.3, bounce=.4}
physics.addBody(floor, "static", staticMaterial)
physics.addBody(lWall, "static", staticMaterial)
physics.addBody(rWall, "static", staticMaterial)
physics.addBody(ceiling, "static", staticMaterial)
--\> Add balloons to stage and position
local balloon = display.newImage("soccerball.png")
balloon.x = display.contentWidth/2
physics.addBody(balloon, {bounce = 0.4, friction = .2} )
--\> Add floor image and position
local floor = display.newImage("soccerfield.png")
floor.y = display.contentHeight - floor.stageHeight/2
physics.addBody(floor, "static", { friction = 1.0 })
-- Define our touch event listener.
function doImpulse(event)
balloon:applyLinearImpulse( 0, -0.2, event.x, event.y )
end
-- Add the listener to our balloon
balloon:addEventListener("touch", doImpulse)
The main problem I’ve noticed thus far is that the soccer ball still seems to act like a balloon and not a ball.
Any help/guidance would be greatly appreciated. Thank you for taking the time to read this.
-Andrew [import]uid: 72845 topic_id: 11839 reply_id: 311839[/import]