Request for slightly more sophisticated game samples

I’m not sure if I am the only person switching from GameSalad to Corona, but I am having trouble with some core gaming concepts in Corona. It would be very helpful to see some examples from Ansca that highlight the following gaming concepts:

I’m going to use Angry Birds as an example, because everyone know that one.

  1. Multi-level (or stages) game design like the different levels in Angry Birds (in GameSalad, you create “scenes”, what is the best way to design this in Corona?)

  2. “Camera” control for worlds larger than 320x480. In Angry Birds, you can swipe left to pan right to view more of the world. It also zooms out and the camera follows the bird when the bird is launched. Since Corona doesn’t have the concept of a “canvas”, the only way I can imaging this working is by moving all of the background objects when you want the appearance of a larger world. Is there something built into Game Edition that makes this a little more automatic?

Ansca, what do you think about providing some examples that show off this functionality? Is anyone else interested in something like this?
Dave [import]uid: 8194 topic_id: 1685 reply_id: 301685[/import]

The game world /canvas is an easy one. You can use groups, specifically creating a group for the world and inserting every game object, background etc… in it.

You would probably have multiple groups, for elements different, for example the background would be a group containing images/textures for the whole length of the game area. The birds would be individual sprites / groups, maybe all contained in a group, or each individually inserted into the world group.

I tend to leave the world group global so everything can see / access it.

Then moving the world group would move everything but as each internal group retains its own inner coordinates the individual elements dont react to the world changing and instead carry on along their own x,y coordinate system.

See this demo http://www.alienhorde.com/files/joystick_1_0.zip for a simple concept with the tileEngine, it uses a masterGroup for rotation and a backgroundGroup to contain and move the background.

Scaling the world would then be achieved using

masterGroup.xScale = masterGroup.yScale = [import]uid: 5354 topic_id: 1685 reply_id: 4947[/import]

Thanks Matthew!

That is a great example of how to make larger worlds with a repeating background image. I’m looking at the code and I understand what it’s doing, but I’m still unclear as to how this can be related to an Angry Birds style game. What I mean is how would you place target objects off-screen and have the “camera” follow, for example, a bullet moving toward the off-screen targets?

Is it simply a matter of giving the targets x,y coordinates greater than the screen dimensions and changing the tileEngine to use the x,y position of the bullet instead of the joystick? [import]uid: 8194 topic_id: 1685 reply_id: 4950[/import]

Hi dknell

Yeah only really look at the grouping in that example, the background is a quick effect to demo the joystick. Im doing a tile engine next.

As for angry birds, quick idea so I would need to test

  1. Setup a 2 world groups, one inside the other, put the background in there and the bullets etc… in the inner world group

  2. Setup a function called moveWorld. This is the camera, of sorts. moveWorld would have 2 primary functions, 1 to move the world in the x direction and the second to scale the world.

moveWorld would have a few possible inputs, so over rides would need to be written but I would write a drag / touch function for the screen to move the world and another one to focus on an object and follow it in the world.

the zoom would be handled like this, which is the genius of the groups (if it works like this)…

the inner group, never scaled just moved in the x , y direction. This will allow you to do things like following the bullet, bird etc… as the group and the internal objects are all using the same coordinate system. Moving the world or focusing on a bird would just be a case of calculating the offset between the bird and the inner world and how much to move that world group by.

Zooming would mean scaling the outer world group (im rotating in the plane example, but scaling would work just as well, try altering my code), probably round the centre of the screen (set references like plane example). This has the effect of zooming the entire world but the internal coordinate system of the inner world group remain the same. [import]uid: 5354 topic_id: 1685 reply_id: 4952[/import]

dknell… check out the parallax demo

http://developer.anscamobile.com/forum/2010/11/08/parallax-scrolling-module-posted-code-exchange [import]uid: 6645 topic_id: 1685 reply_id: 10785[/import]