hey all,
i have a bit of code thats works fine when its not integrated with composer but when i put it in composer o get a black screen (no errors). I know its a lot of code to wade through but i think im missing something simple.
local composer = require( "composer" ) local scene = composer.newScene() --------------------------------------------------------------------------------- -- All code outside of the listener functions will only be executed ONCE -- unless "composer.removeScene()" is called. --------------------------------------------------------------------------------- -- local forward references should go here display.setStatusBar( display.HiddenStatusBar ) local W = display.viewableContentWidth local H = display.viewableContentHeight local X = display.contentCenterX local Y = display.contentCenterY local XO = display.screenOriginX local random = math.random --------------------------------------------------------------------------------- -- "scene:create()" function scene:create( event ) local sceneGroup = self.view local background = display.newImage("background3.png") sceneGroup:insert( background) background.anchorX = .5 background.anchorY = .5 background.x = X background.y = Y local sun = display.newImage("sun.png") transition.to( sun, {time = 100000, x = W} ) local buildbutton = display.newImage("BuildButtonM.png") sceneGroup:insert(sun) sceneGroup:insert(buildbutton) buildbutton.x = W \* .9 buildbutton.y = H \* .88 local function BuildCLoud (params) local Ypos = random(30,Y) local cloud = display.newImage(params.image ) sceneGroup:insert(cloud) cloud.anchorX = 0 cloud.x = W cloud.y = Ypos cloud.speed = params.speed return cloud end local params = { {image = "Cloud1.png", speed = .5}, {image = "Cloud2.png", speed = .2}, {image = "Cloud3.png", speed = .3}, {image = "clouds4.png", speed = .3}, } local cloudtable = {} for \_,item in ipairs( params ) do local ball = BuildCLoud( item ) cloudtable[#cloudtable+1] = ball end local function MoveClouds (event) for \_,ball in ipairs( cloudtable ) do if ball.x \<= XO - ball.width then print( "reached" ) ball.x = W ball.y = random (30, Y) ball.speed = random (2,5)\*.1 else ball:translate( -ball.speed, 0 ) end end end -- Initialize the scene here. -- Example: add display objects to "sceneGroup", add touch listeners, etc. buildbutton:addEventListener( "touch", ToShop ) Runtime:addEventListener( "enterFrame", MoveClouds ) -- Initialize the scene here. -- Example: add display objects to "sceneGroup", add touch listeners, etc. end --------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) --------------------------------------------------------------------------------- return scene