Needs help...

guys here i am again, i actually finished the codes specifically to the game itself and it runs smoothly and perfectly as per its concept. but my problem now is when creating a scene it has an error saying like this “attempt to index local ‘background’ (a nil value)”.

function scene:create( event )

    local sceneGroup = self.view

    – Code here runs when the scene is first created but has not yet appeared on screen

    local background = display.newImageRect( sceneGroup, “iqolors.png”, 360, 571 )

    background.x = display.contentCenterX

    background.y = display.contentCenter

    

    local playButton = display.newText( sceneGroup, “Play”, display.contentCenterX, 700, native.systemFont, 44 )

    playButton:setFillColor( 0.82, 0.86, 1 )

    

    local highScoresButton = display.newText( sceneGroup, “High Scores”, display.contentCenterX, 810, native.systemFont, 44 )

    highScoresButton:setFillColor( 0.75, 0.78, 1 )

    

    playButton:addEventListener( “tap”, gotoGame )

    highScoresButton:addEventListener( “tap”, gotoHighScores )

end

   

i dont know what’s wrong with this, “iqolors” is the file name of the picture. Needs help guys!

i found the mistake guys… :slight_smile:

now i am facing new problem guys, i am making the first scene of my game and i already made the background and design. i wonder why it zoomed in… i set the background’s width and height the same to its default value. then i followed the codes on the tutorial. i dunno where the problem is! can somebody help me or share some code…thank you!

Well, as you are the one who is experiencing the issues, you should do the following:

  1. Explain what it is what you are trying to accomplish.

  2. Explain what is actually occurring.

  3. Create a small sample project that you can upload here which demonstrates the issue.

If by zoomed in, you mean that the image is scaled up and blurry, then that is because of automatic scaling. You should also check what the actual dimensions of the image you are using are and compare them to what dimensions you are using in Corona, i.e. is the image smaller than the imageRect (or whatever display object) you are creating.

thank you for your response sir, well in my case, in the beginning of my project i set it to PHONE PRESET which has a width of 320 and a height of 480, so i have made a background design in my first scene to the same width which is 320 and its height to 480. then i followed all the instruction in the tutorial for scene-template but the result was different. although the background is displayed but it zoomed in a bit that only part of the center is seen in the screen.  

again, your usual support to the newbies is much highly appreciated sir. thank you so much.

If you open your simulator and press “View”, then “View As”, then what device are you simulating? If you don’t see your device there, you can see if you find it from inside the “Borderless” menu.

My guess is that if you are using a background image that is exactly 320x480, then you are simulating a taller or wider device, which means that the images won’t scale to fit all sides. I’d recommend you read through this article to see if it explains your issue better: https://coronalabs.com/blog/2018/08/08/understanding-content-scaling-in-corona/

Sir it’s me again, do you have any idea about this problem?

guys i check the path in C and there’s no game.dll there. because the problem says no file: game.dll , my Question where can i download this game.dll or if i can find one online is it suitable for my project? Does it excluded at the time when installed my CORONA SDK?

Apologies for questioning and asking a lot. 

Please don’t refer to me as sir, that’s just weird, just call me XeduR.

Also, I would recommend that you open new threads when you have new problems and/or questions that are not connected to the previous one. Like with these new questions.

As for your issue, it seems that you are trying to load some module that doesn’t exist, i.e. you’ve tried to require a Lua file that does not exist, either at all or not at that location. See http://lua-users.org/wiki/ModulesTutorial.

thank you for the response Xedur, actually it is connected to the previous one. when i finished all the scene in my game then when i clicked PLAY button that error was displayed. 

Yes, but it is quite loosely connected. It may be the next issue you ran into when developing your project, but for someone like me, it is an entirely new issue, as was your previous issue and the one before that, all on this one thread.

One of the best things about forums like these is that if someone can clearly explain their problem and another person can clearly answer their question, then such threads may also help other people who run into similar issues in the future. This is a big part of why it is so useful to have descriptive titles for your threads and to stick to one issue per thread. It makes the threads easier for others to find.

By posting about new issues to the same old thread, others become less likely to help you out with said issues.