Seeking some advice on making this game.

Hi,

I’m new to Corona but I a good background in programming and game development. I’m recreating this game in Corona and wanted to know what are proper “Corona way” in order to do them. It would be nice if one would give me clues on what I have to do here and there, then I can find my way around:

I have two big boxes on sides of the screen that act as goals and you have to put balls in them. There are balls on the screen that are bouncing and moving and should not enter that goal zone by themselves, only if player drags and releases them on those goal boxes.

There are other details such as random spawning/generation of balls among other things but I don’t want to get there now.

So to break it down:

  1. I think I can find how to make balls move all the time and bounce with the edges of the screen but how can I make balls not enter those goal zones and only if player drags and drops them there?

(I’m thinking to make those zones as rigidbodies so balls would not enter it, then when player grabs one, it would disable physic on the grabbed object so it can enter those zones and when player release a ball, it would check to see if it’s whether in those zones and if it’s not, enable physic on it again.)

  1. How I can limit player’s drag and drop objects so he or she cannot drag and drop on some obstacles, like borders of the screen or other stuff? For example if there is a big obstacle on middle of the level, how we can make the object not get into if if player grabs an object and moves it into that obstacle?

  2. How I can define goal zones on each level? Does it have to be hard coded with numbers or I can do it with defining boxes and use physic?

I’m saying this again, I’m not asking anyone to write any code for me, I’m just seeking some advice as all I can find are very simple tutorials on Corona rather than how to make a real game from ground up. [import]uid: 206803 topic_id: 34255 reply_id: 334255[/import]

  1. You will have a function that moves your event.target most likely so you just do this:
if event.phase == "began" then  
event.target.isBeingTouched = true  
end  
if event.phase == "ended" then  
event.target.isBeingTouched = false  
end  

Now you just add an if statement if target isBeingTouched == true than you can let it go in the goal.
2) Do you want him to not be able to drag OR drop on obstacles? or only drop?

  1. I don’t completely understand what you mean by this. But you will have to set the x and y for the goal zones, the rest can be exactly the same, just change x and y for different levels and should be fine. You can also change rotation along with x and y but besides that it should have the same coding so you wouldn’t have to change anything besides those values.
    and
    http://learningcorona.com/

Hope this made sense wrote this really fast, will check back later [import]uid: 77199 topic_id: 34255 reply_id: 136225[/import]

Hello,
Welcome to Corona! Almost everything you describe here is optimally accomplished using the physics engine… balls bouncing, setting up sensor regions as goals, changing bodies from dynamic to kinematic type, etc. My advice would be to explore the physics engine and APIs to learn all of the cool things you can do. Any specific questions, don’t hesitate to ask here in the forums; there are a lot of people who can help with the details.

http://developer.coronalabs.com/content/game-edition-box2d-physics-engine

Best regards,
Brent Sorrentino [import]uid: 200026 topic_id: 34255 reply_id: 136245[/import]

I’d also check out the dragBody function in the UI module… That seems to be what you need for moving the balls around - it won’t let you drag a body into another one. [import]uid: 147322 topic_id: 34255 reply_id: 136261[/import]

  1. You will have a function that moves your event.target most likely so you just do this:
if event.phase == "began" then  
event.target.isBeingTouched = true  
end  
if event.phase == "ended" then  
event.target.isBeingTouched = false  
end  

Now you just add an if statement if target isBeingTouched == true than you can let it go in the goal.
2) Do you want him to not be able to drag OR drop on obstacles? or only drop?

  1. I don’t completely understand what you mean by this. But you will have to set the x and y for the goal zones, the rest can be exactly the same, just change x and y for different levels and should be fine. You can also change rotation along with x and y but besides that it should have the same coding so you wouldn’t have to change anything besides those values.
    and
    http://learningcorona.com/

Hope this made sense wrote this really fast, will check back later [import]uid: 77199 topic_id: 34255 reply_id: 136225[/import]

Hello,
Welcome to Corona! Almost everything you describe here is optimally accomplished using the physics engine… balls bouncing, setting up sensor regions as goals, changing bodies from dynamic to kinematic type, etc. My advice would be to explore the physics engine and APIs to learn all of the cool things you can do. Any specific questions, don’t hesitate to ask here in the forums; there are a lot of people who can help with the details.

http://developer.coronalabs.com/content/game-edition-box2d-physics-engine

Best regards,
Brent Sorrentino [import]uid: 200026 topic_id: 34255 reply_id: 136245[/import]

I’d also check out the dragBody function in the UI module… That seems to be what you need for moving the balls around - it won’t let you drag a body into another one. [import]uid: 147322 topic_id: 34255 reply_id: 136261[/import]