Hi
The below code loops ten times from the gametimer but only one image is displayed, or appears to be. What is wrong with my code?
Thanks
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
local centerX = display.contentCenterX;
local centerY = display.contentCenterY;
local ball1
_W = display.contentWidth
_H = display.contentHeight
local physics = require(“physics”)
physics.start( )
physics.setGravity( xGravity, yGravity)
local function startgame()
ball1.x = math.random(display.contentWidth)
ball1.y = display.contentHeight-4 --tried different number here
physics.addBody(ball1, {bounce = 0.6, friction =0.1, radius=45})
ball1:setLinearVelocity(900,1500)
end
function scene:createScene( event )
local group = self.view
local group = scene.view;
local bg = display.newImageRect(group, “IMG/bgBlack.png”, totalWidth, totalHeight);
bg.x, bg.y = centerX, centerY;
local left_wall = display.newRect(0,0,2,_H*2)
physics.addBody(left_wall,“static”, {bounce = 0.5, friction=0.5,filter = boarderCollsionFilter})
left_wall.myName = “Left Wall”
local right_wall = display.newRect(_W-1,0,2,_H*2)
physics.addBody(right_wall,“static”, {bounce = 0.5, friction=0.5,filter = boarderCollsionFilter})
right_wall.myName = “Right Wall”
local top_wall = display.newRect(0,0,_W*2,2)
physics.addBody(top_wall,“static”, {bounce = 0.5, friction=0.5,filter = boarderCollsionFilter})
top_wall.myName = “Top Wall”
local bottom_wall = display.newRect(0,_H,_W*2,2)
physics.addBody(bottom_wall,“static”, {bounce = 1, friction=0.5,filter = boarderCollsionFilter})
bottom_wall.myName = “Bottom Wall”
gametimer = timer.performWithDelay( 20, startgame, 10)
end
– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view
ball1 = display.newImage(group, “IMG/image1.png”,10)
end