Help with my simulator display problem.

Hello everyone I am trying to recreate a Breakout game I started the code. but i try to run on the simulator I get a black display.

here’s my code:

display.setStatusBar(display.HiddenStatusBar)

local physics = require “physics”

 physics.start()

 physics.setGravity(0, 0)

 system.setAccelerometerInterval( 100 )

local menuScreenGroup – display.newGroup()

local mmScreen

local playBtn

local background

local paddle

local brick

local ball

local scoreText

local scoreNum

local levelText

local levelNum

local alertDisplayGroup  

local alertBox

local conditionDisplay

local messageText

local_W = display.contentWidth / 2

local_H = display.contentHeight / 2

local bricks = display.newGroup()

local brickWidth = 35

local brickHeight = 15

local row

local column

local score = 0

local scoreIncrease = 100

local currentLevel

local vx = 3

local vy = -3

local gameEvent = “”

local isSimulator = “simulator” == system.getInfo (“environment”)

function main()

mainMenu()

end

function mainMenu()

 menuScreenGroup = display.newGroup()

 mmScreen = display.newImage (“images/mmScreen.png”, 0, 0, true)

 mmScreen.x = _W

 mmScreen.y = _H

 playBtn = display.newImage (“playbtn.png”)

 playBtn:setReferencePoint (display.CenterReferencePoint)

 playBtn.x = _W; playBtn.y = _H + 50

 playBtn.name = “playbutton”

 menuScreenGroup: insert(mmScreen)

 menuScreenGroup: insert(playBtn)

 playBtn:addEventListener(“tap”, loadGame)

end

function loadGame(event)

if event.target.name == “playbutton” then

transition.to(menuScreenGroup, {time = 0, alpha=0, omComplete = 

addGameScreen})

playBtn:removeEventListener(“tap”, loadGame)

  end

end

It might help to start with this guide:

http://docs.coronalabs.com/guide/basics/debugging/index.html

Rob

Hello Rob thank you for the reply. I am still having problems with the display images.

 i just just started another tutorial and no success.

my image is displayed on top let of the screen 

i tried

local background = display.newImage(“bg.png”)

config.lua

application = {
content = {
fps = 60,
width = 320,
height = 480,
scale = “zoomEven”,
– xAlign = “center”,
–yAlign = “center”,
imageSuffix = {
["@2x"] = 2;
},
},
}

 main.lua

local background = display.newImage(“images/clouds.png”,230,150, true);

local background = display.newImage(“images/clouds.png”);
background.anchorX = 0
background.anchorY = 0

local background = display.newImage(“images/clouds.png”);
background.x = display.contentCenterX
background.y = display.contentCenterY

Are you getting errors in your console.log?

Can you please post your code inside the appropriate [lua] and [/lua] tags (with out the spaces)?

Why are you loading the background image three times?

Rob

i am not loading the background image 3 times those are all three different codes i tried in the main.lua. i tried on code at time. and i still can’t get the image to display on the simulator. i tried the debug on Xcode same result

i a have a background image named bg.png all i am trying to do is to load the background image using the code

config.lua

application =

{

        content =

        {

        width = 640,

height = 960, 

scale = “letterbox”,

fps = 60,

        },

}

main.lua

local background = display.newImage(“images/bg.png”)

no error on the simulator

Corona Simulator Console


Diagnostics and Lua print output will appear here

 

Jan 18 18:09:55.826: 

Copyright © 2009-2014  C o r o n a   L a b s   I n c .

Jan 18 18:09:55.826: Version: 3.0.0

Jan 18 18:09:55.826: Build: 2014.2511

Jan 18 18:09:55.839: Platform: iPad / x86_64 / 10.10 / ATI Radeon HD 2600 PRO OpenGL Engine / 2.1 ATI-10.0.19 / 2014.2511

Jan 18 18:09:56.069: The file sandbox for this project is located at the following folder:

(/Users/rodrigodeoliveira/Library/Application Support/Corona Simulator/Break Out-BE9928AE9DC5169530E952F11EC02DD7)

Jan 18 18:09:56.169: WARNING: Accelerometer events are only available on the device.

If you call display.newImage(filename)  and do nothing else the X and Y locations of the image (it’s center) will be 0, 0.  This causes the image to draw at the top left corner.   If you say:

local background = display.newImage( filename, x, y )

where x, y are the X and Y where you want to center the image it will do so.  You can always explicitly set the location of the image:

local background = display.newImage( filename )

background.x = yourXLocation

background.y = yourYLocation

Rob

It might help to start with this guide:

http://docs.coronalabs.com/guide/basics/debugging/index.html

Rob

Hello Rob thank you for the reply. I am still having problems with the display images.

 i just just started another tutorial and no success.

my image is displayed on top let of the screen 

i tried

local background = display.newImage(“bg.png”)

config.lua

application = {
content = {
fps = 60,
width = 320,
height = 480,
scale = “zoomEven”,
– xAlign = “center”,
–yAlign = “center”,
imageSuffix = {
["@2x"] = 2;
},
},
}

 main.lua

local background = display.newImage(“images/clouds.png”,230,150, true);

local background = display.newImage(“images/clouds.png”);
background.anchorX = 0
background.anchorY = 0

local background = display.newImage(“images/clouds.png”);
background.x = display.contentCenterX
background.y = display.contentCenterY

Are you getting errors in your console.log?

Can you please post your code inside the appropriate [lua] and [/lua] tags (with out the spaces)?

Why are you loading the background image three times?

Rob

i am not loading the background image 3 times those are all three different codes i tried in the main.lua. i tried on code at time. and i still can’t get the image to display on the simulator. i tried the debug on Xcode same result

i a have a background image named bg.png all i am trying to do is to load the background image using the code

config.lua

application =

{

        content =

        {

        width = 640,

height = 960, 

scale = “letterbox”,

fps = 60,

        },

}

main.lua

local background = display.newImage(“images/bg.png”)

no error on the simulator

Corona Simulator Console


Diagnostics and Lua print output will appear here

 

Jan 18 18:09:55.826: 

Copyright © 2009-2014  C o r o n a   L a b s   I n c .

Jan 18 18:09:55.826: Version: 3.0.0

Jan 18 18:09:55.826: Build: 2014.2511

Jan 18 18:09:55.839: Platform: iPad / x86_64 / 10.10 / ATI Radeon HD 2600 PRO OpenGL Engine / 2.1 ATI-10.0.19 / 2014.2511

Jan 18 18:09:56.069: The file sandbox for this project is located at the following folder:

(/Users/rodrigodeoliveira/Library/Application Support/Corona Simulator/Break Out-BE9928AE9DC5169530E952F11EC02DD7)

Jan 18 18:09:56.169: WARNING: Accelerometer events are only available on the device.

If you call display.newImage(filename)  and do nothing else the X and Y locations of the image (it’s center) will be 0, 0.  This causes the image to draw at the top left corner.   If you say:

local background = display.newImage( filename, x, y )

where x, y are the X and Y where you want to center the image it will do so.  You can always explicitly set the location of the image:

local background = display.newImage( filename )

background.x = yourXLocation

background.y = yourYLocation

Rob