So, i started to learn Corona SDK and found some video tutorials on YouTube
http://www.youtube.com/watch?v=DL_or4XKTfU&feature=player_detailpage
i’ve made exactly like in this video, but i get errors in end and cant figure out what i did wrong
If anyone can pinpoint my mistake in tutorial code, i’ll be glad
sadly i cant reach the maker of video
Terminal says: main.lua:77:attempt to call ‘planets’
main.lua:77: in function ‘newPlanet’
\_W = display.contentWidth
\_H = display.contentHeight
m = {}
m.random = math.random
local physics = require("physics")
physics.start()
physics.setDrawMode("hybrid")
local Scene = display.newGroup()
local BG = display.newGroup()
local Planets = display.newGroup()
local Basket = display.newGroup()
Scene:insert(BG)
Scene:insert(Planets)
Scene:insert(Basket)
--Basket
local function newBasket()
local g = display.newGroup()
local body = display.newImage("images/basket2.png")
--????? ?? ???? 0,0
body.x = 0; body.y = 0
local physics\_body = {}
physics\_body["basket"] = {
{
density = 0, friction = 0, bounce = 0,
shape = {-143,-80, -120,-80, -88,62, -110,62}
},
{
density = 0, friction = 1, bounce = 0,
shape = {-110,62, 106,62, 106,72, -110,72}
},
{
density = 0, friction = 0, bounce = 0,
shape = {120,-80, 140,-80, 106,62, 84,62}
}
}
physics.addBody(g, unpack(physics\_body["basket"]))
g:insert(body)
g:setReferencePoint(display.CenterReferencePoint)
return g
end
local function newPlanet()
local g = display.newGroup()
local planets = {
{img="earth.png", radius=30},
{img="sun.png", radius=60},
{img="moon.png", radius=20}
}
local n = math.random(1,3)
local img = "images/" .. planets(n).img
local ball = display.newImage(img)
ball.x = 0; ball.y = 0
physics.addBody(g, {bounce=0.3, radius=planets[n],radius})
g:insert(ball)
g:setReferencePoint(display.CenterReferencePoint)
return g
end
local bg = display.newRect(0,0,\_W,\_H)
bg.x= \_W \* 0.5; bg.y = \_H \* 0.5
bg:setFillColor(255,255,255,155)
BG:insert(bg)
local ground = display.newRect(0,0,\_W,5)
local left\_wall = display.newRect(0,0,5,\_H)
local right\_wall = display.newRect(0,0,5,\_H)
ground:setReferencePoint(display.CenterReferencePoint)
ground.x = \_W \* 0.5; ground.y = \_H - (ground.height \* 0.5)
left\_wall:setReferencePoint(display.CenterReferencePoint)
left\_wall.x = 0 - (left\_wall.width \* 0.5); left\_wall.y = \_H \* 0.5
right\_wall:setReferencePoint(display.CenterReferencePoint)
right\_wall.x = \_W + (right\_wall.width \* 0.5); right\_wall.y = \_H \* 0.5
physics.addBody(ground, "static", {friction = .2, bounce = .1})
physics.addBody(left\_wall, "static")
physics.addBody(right\_wall, "static")
BG:insert(ground)
BG:insert(left\_wall)
BG:insert(right\_wall)
local basket = newBasket()
basket.x = \_W \* 0.5; basket.y = \_H-200
Basket:insert(basket)
local p = {}
local function spawnPlanets(number)
local function spawn(e)
local planet = p[e.count]
planet = newPlanet()
planet.x = math.random((\_W \* 0.5)-50, (\_W \* 0.5)+50)
planet.y = 0
Planets:insert(planet)
if(e.count == number) then
timer.cancel(tmr)
tmr = nil
end
end
tmr = timer.performWithDelay(500, spawn, number)
end
spawnPlanets(20)
[import]uid: 16142 topic_id: 10739 reply_id: 310739[/import]