Putting images on the screen and moving them around — that’s the core of game development. In this first series of videos you’ll see how easy Corona SDK allows you to get that done.
Sample code (right click to download): Right-click to download GameDev-03-DisplayAnimate.zip file
Video 1: Display An Image (13:46)
Video 2: Animating An Image (10:50)
Video 3: Display Multiple Images – A Pro Trick! (13:19
“I’m unclear on the following:
pads[idx] = pad
pads[idx].idx = idx
Specifically the difference between what the second line does compared to the first.”
Part of the problem is that I used the variable idx THREE times in that one line. D’oh! If I had done this:
pads[idx].padNumber = idx
…it may have been a little more clear. And maybe this will help explain it better…
That first line says, “I just created an object called pad and I need some place to store it — I know, I’ll put it in the pads table at the location referenced by idx. So if idx = 3 at that point, I’ll be storing this pad object in the third location of the pads table.”
That means any time you want to make use of that specific pad object, you can get it with this: myPad = pads
It’s like having a tall chest of drawers and you put that pad object into the third drawer down. Unless you shuffle things (or your kids get in and mess things up) that particular pad is always going to be available in that drawer.
And the second line? That’s like putting a sticky note titled idx on that drawer with #3 written on it.
You can open the drawer and grab that lily pad and you can look at the sticky note to see which lily pad it is.
Let’s say you were doing something similar and were creating lily pads of different colors. You could add a third line to the example above that looked like this:
pads[idx].color = “orange”
That’s like a sticky note for that drawer titled color that says orange.
So now you have a bunch of drawers with lily pads – and you can look at the sticky notes for each drawer and say, “Oh, this one is color orange. That one, with an idx of 3, has a color of blue.” And so on.
Video 4: Triggering Code After an Animation (7:22)
Back to the Game Dev Dashboard