Game Development Reference
In-Depth Information
Figure 8-6. Transformations applied to the rectangle
Groups
All display elements can be placed in a group. Think of a group as a container that can hold display
elements. The advantage of a group is that by manipulating the position and display attributes of the
group, you can affect all of the display elements held in the group together. You can move, rotate,
and scale them, and you can change their alpha property and the visibility.
local grp = display.newGroup()
local text1 = display.newText("One", 10, 10)
local text2 = display.newText("Two", 10, 30)
local text3 = display.newText("Cha-Cha Cha", 10, 50)
When we run this, three lines of text are displayed on the screen. We can relocate any one of them
by modifying the x or y position of the elements. Add the following code to the end of the preceding
code. To rerun or refresh, simply press ⌘+R on the Mac or Ctrl+R on Windows. Corona SDK also
monitors the directory for changes and will offer the option to relaunch the project if it is changed.
text2.y = 90
 
Search WWH ::




Custom Search