Needs help...

i’m new to corona like a month ago, i tried API references but as a newbie i have a hard time understanding those syntax(some of it).

could you please guide me? i’m working on a simple game where i have 4 different objects which serve as my buttons positioned at the bottom of the screen then a random object drops from the top of the screen then all you have to do is to press/match your buttons to the object falling from the top, if the object and button you press matched then the object disappear in the screen otherwise game over if it reaches down to the bottom.   

Thank you!

I recommend that you get acquainted with the Corona Getting Started guide and the demo projects available at https://docs.coronalabs.com/guide/programming/index.html.

**These instructions teach you how to make a game

Chapter 1 to Chapter 8

https://docs.coronalabs.com/guide/programming/01/index.html**

 

That’s just the same link as above :stuck_out_tongue:

can you guys share your expertise/knowledge or kind of a bit of code maybe 10 lines of codes on how to connect your execution on one object to another i mean if you press thisObject it will connect to thatObject.

please bear with me, i am just trying to learn! thank you…

local object = display.newRect( display.contentCenterX, display.contentCenterY-120, 200, 120 ) object.colour = "red" object:setFillColor( 1, 0, 0 ) local function changeColour() if object.colour == "red" then object.colour = "green" object:setFillColor( 0, 1, 0 ) else object.colour = "red" object:setFillColor( 1, 0, 0 ) end end timer.performWithDelay( 1000, changeColour, 0 ) local button = display.newCircle( display.contentCenterX, display.contentCenterY+60, 50 ) button.id = "the circle" local function onObjectTouch( event ) if ( event.phase == "began" ) then print( "Touch event began on: " .. event.target.id .. " and the rectangle was " .. object.colour ) object.y = object.y - 20 elseif ( event.phase == "ended" ) then print( "Touch event ended on: " .. event.target.id .. " and the rectangle was " .. object.colour ) object.y = object.y + 20 end return true end button:addEventListener( "touch", onObjectTouch )

Here’s a simple demo where pressing the white circle in the middle will move the rectangle above it and print out the rectangle’s colour, which changes based on a timer.

big thanks man… my program run, but it is still a long way to go. although i have a different concept style of game and i just followed your codes and it works… i really appreciate it for helping me! cheers…

local object1 = display.newImageRect(…)

–some codes here

local object2 = display.newImageRect(…)

–some codes here

local object3 = display.newImageRect(…)

–some codes here

local object4 = display.newImageRect(…)

–some codes here

local object5 = display.newImageRect(…)

–some codes here

local object6 = display.newImageRect(…)

–some codes here

 

local function onButtonTouch1 (event)

if (event.phase == “began”) then
print("Touch event began on: " … event.target.id … "and the button was pressed ")

if(event.target.id == “button1” ) then --THIS IF STATEMENT DOES NOT WORK, PLEASE NEED HELP!

if(rectangle == object1 )then --THIS IF STATEMENT DOES NOT WORK, PLEASE NEED HELP!
object1 :removeSelf()
table.remove(myObjectTable)

elseif(rectangle == object2 )then --THIS IF STATEMENT DOES NOT WORK, PLEASE NEED HELP!
object2:removeSelf()
table.remove(myObjectTable)

elseif(rectangle == object3) then --THIS IF STATEMENT DOES NOT WORK, PLEASE NEED HELP!
object3:removeSelf()
table.remove(myObjectTable)

elseif(rectangle == object4)then --THIS IF STATEMENT DOES NOT WORK, PLEASE NEED HELP!
object4:removeSelf()
table.remove(myObjectTable)

elseif(rectangle == object5) then --THIS IF STATEMENT DOES NOT WORK, PLEASE NEED HELP!
object5:removeSelf()
table.remove(myObjectTable)

elseif(rectangle == object6) then --THIS IF STATEMENT DOES NOT WORK, PLEASE NEED HELP!
object6:removeSelf()
table.remove(myObjectTable)

else
event.target.id = nil

end
end

elseif (event.phase == “ended”) then
print("Touch event ended on: " … event.target.id … “and the button was not pressed”)
end
return true

 

local rectangle = display.newRoundedRect( …)

rectangle.id = “button1”

rectangle:addEventListener(“touch”, onButtonTouch1)

Please format your code using the code tags to make it easier to read.

I won’t get into the reasons why that code isn’t the greatest way of doing things, but for now your “rectangle” object is out of scope of the touch handler, it should be defined before it.

https://docs.coronalabs.com/tutorial/basics/scope/index.html

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.