Game Development Reference
In-Depth Information
Images
One of the advantages of choosing Lua over languages such as C, C++, or Objective-C is that the
need for allocating and deallocating memory is made redundant. The wrappers that the frameworks
provide allow for easier coding compared to native code. When using Corona SDK, we can load and
display images on the screen with ease.
To load an image, we use the newImage function in the display namespace:
local img = display.newImage("image1.png")
Alternatively, we can also provide the coordinates where we might want the image to be located:
image1.png and place it at the position 50, 50 on the screen.
longer necessarily synchronous in their flow. Events can occur and need to be handled at various
times in an app's life cycle.
To enable us to use GUI-based applications, the concept of event-based programming was introduced.
As shown in the diagram in Figure 8-8 , in this type of processing, an event occurs and is passed
to the application to be processed, and based on the event type, the application does what's
necessary. In our case, the most commonly used event that we shall be working with is the touch
event. That is the primary source of all input to the application. To allow the code to listen to the
events that occur, the program has to register itself as a listener for a particular event and also pass
a handler to the program that is called when the event occurs.
 
Search WWH ::




Custom Search