I don't find the mistake, HELP, please

Hi, everyone, i’m really new at this, so i tried to do the tutorial, but i got stuck in a part and i don’t know what’s wrong.

Hello and welcome to the community!

When asking for help, you’ll need to be more specific. When you say: “so i tried the tutorial, but…”, none of us will have any idea as to what you are talking about because there are hundreds, if not thousands of tutorials available online.

So, when you are experiencing issues with some particular tutorial or topic, then please provide a link to it.

After providing a link, you should also explain 1) what it is that you did, 2) what you wanted to happen, and 3) what actually happened.

Providing access to the code, via link to the tutorial for instance, and answering these three key questions will make it easier (and even possible) for others to help you.

If you post code here in the forum you should see a button that looks like this < / > . Use that to format the code and make it more easily readable for other readers.

Additionally, try to keep it relevant to where you think the issue lies. If you think you have a problem somewhere between line 30-40 in your code, don’t paste the entire 3000 line file as nobody will want to comb over the whole thing. Just paste in the snippet in question.

And please please please do not post screenshots of code, paste the text itself here. If someone wants to try and reproduce your problem to help fix it for you, they are not going to want to manually copy and type it out from a reference screenshot.

1 Like

I was trying to attach the code, but I can’t, bacause i’m new. So, I accidentaly sent this for mistake.
Ok, but the link to the tutorial is this: https://docs.coronalabs.com/guide/programming/02/index.html

So, what I wanted to do was put the ship, the lives and the score in the screen with the background. Like the tutorial, i have done this:

<local backGroup = display.newGroup()
local mainGroup = display.newGroup()
local uiGroup = display.newGroup()

local background = display.newImageRect( backGroup, “background.png”, 800, 1400 )
background.x = display.contentCenterX
background.y = display.contentCenterY

ship = display.newImageRect( mainGroup, objectSheet, 4, 98, 79 )
ship.x = display.contentCenterX
ship.y = display.contentHeight - 100
physics.addBody( ship, { radius = 30, isSensor = true } )
ship.myName = “ship”

livesText = display.newText( uiGroup, "Lives: " … lives, 200, 80, native.systemFont, 36 )
scoreText = display.newText( uiGroup, "Score: " … score, 400, 80, native.systemFont, 36 )

display.setStatusBar( display.HiddenStatusBar )

local function updateText()
livesText.text = "Lives: " … lives
scoreText.text = " Score: " … score
end />

I think the mistake is here, because the simulator only shows the background, and this is the part of the code that should do that.

Looking at your code, it seems that you skipped Loading Image Sheets part of the tutorial which breaks your code when creating the ship from the image sheet.

ship = display.newImageRect( mainGroup, objectSheet, 4, 98, 79 )

This part breaks because there is no objectSheet at the moment. If you create and initialize objectSheet before that part like it does in tutorial, this should work.

By the way, there are links to the whole sample project in the tutorial. You can always download and inspect the code.

The problem is that i have done that, i simply didn’t copied it to here.

local sheetOptions =
{
frames =
{
{ – 1) asteróide 1
x = 0,
y = 0,
width = 102,
height = 85
},
{ – 2) asteróide 2
x = 0,
y = 85,
width = 90,
height = 83
},
{ – 3) asteróide 3
x = 0,
y = 168,
width = 100,
height = 97
},
{ – 4) nave
x = 0,
y = 265,
width = 98,
height = 79
},
{ – 5) laser
x = 98,
y = 265,
width = 14,
height = 40
},
},
}
local objectSheet = graphics.newImageSheet( “gameObjects.png”, sheetOptions )

Here it is.

And I have compared it with the code they provide and it’s the same code.

Ok, I found the mistake, it’s all working, the problem was the resolution the simulator was using, he wasn’t showing, but know i changed the resolution and it’s all there. Thanks, anyway.