Hey guys,
just found on the web an code that should be working based on the writer of the website.
the code should create an space looking background, but for some reason i cant get it to work and i was wondering what the problem is. i dont get any errors.
this is the code:
main.lua
display.setStatusBar(display.HiddenStatusBar)
local storyboard = require(“storyboard”);–Include the storyboard library
local physics = require(‘physics’)
physics.start()
physics.setGravity(0, 0)
storyboard.gotoScene(“Menu”)
config.lua
application = {
content = {
width = 320,
height = 480,
scale = “letterBox”,
fps = 30,
},
}
menu.lua
local storyboard = require(“storyboard”)
local scene = storyboard.newScene()
function scene:createScene( event )
local scene = self.view
local createStars = function()
for i = 1, 20 do
local star = display.newCircle( math.random( display.contentWidth ), math.random(display.contentHeight), 1 )
star:setFillColor( math.random(200) + 55 )
physics.addBody( star,{ density = 50, friction = 0, bounce = 0, radius = 1 } )
star:applyLinearImpulse( 0, -1, star.x, star.y )
local moveStar = function()
if star.x ~= nil then
if star.x >= 0 then
star:removeSelf()
elseif star.x > 0 then
star.x = star.x - 5
end
end
end
timer.performWithDelay( 1, moveStar, display.contentWidth + 50 )
end
local makeStar = function()
local star = display.newCircle( display.contentWidth + math.random( 20 ), math.random(display.contentHeight), 1 )
star:setFillColor( math.random(200) + 55 )
local moveStar = function()
if star.x ~= nil then
if star.x >= 0 then
--print( “removing” );
star:removeSelf()
elseif star.x > 0 then
star.x = star.x - 5
end
end
end
timer.performWithDelay( 1, moveStar, display.contentWidth + 50 )
end
timer.performWithDelay( 75, makeStar, 0 )
end
end
function scene:enterScene( event )
local scene = self.view
if storyboard.getPrevious() ~= nil then
storyboard.removeScene(storyboard.getPrevious())
end
end
function scene:destroyScene( event )
local scene = self.view
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene
Let me know if you know an answer to this. And i am new to corona. just learned it 3 weeks ago.