Friday, 31 August 2012

Programming for beginners – part 4

programming for beginners - RAM I hope everybody understands my previous posts. If not please let me know what is not clear and I’ll try to clarify.

What you see here is the actual MEMORY. I don’t want to get to technical so I’m just going to say that inside of these little boards resides the information that we are going to work with.

How? we don’t care for now.

Remember last time we were talking about boxes, and variables. So to recap from last week, a ScreenshotSmallvariable is representation of a container, such as a box. It holds information: numbers, names, dates, images, sounds, music, etc. In our case with MINIFONO (or Candy Toy phone) we have a screen where we have all the buttons that represents the numeric pad of a phone. Each of these button’s has different attributes: size, image, location and is tied to a specific functionality, more on that later. For example the number one is a button that has an image attached to it. It also has a position on the screen. A size. So we can say that there are several variables assigned to button number one.

And because there are several of these variables or boxes it’s a good idea to go to the hardware store and buy a bigger box to hold all these variables together. But first let’s define what we know now. And here comes the part were we actually code. In LUA we do it this way.

local buttonOne   <—here we name it, we create the box but we don’t assign any value yet

And since we came back from the hardware store with a bigger box we are going to use it for buttonOne. In it we are going to store the image that was created previously. Like this:

buttonOne = display.newImage(“buttonOne.png”)  <—that’s the way you do it in Corona SDK, more later.

buttonOne now has become the bigger box that will from now on contain the other attributes we discussed just now. In the next episode we will assign the size, the location on screen, etc.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Post a Comment