- Corona SDK Mobile Game Development:Beginner's Guide
- Michelle M. Fernandez
- 413字
- 2021-08-06 19:59:47
Time for some shapes
Another way of creating display objects is using vector objects. You can use vector objects to create shapes, such as a rectangle, rounded rectangle, and circle by using the following:
display.newRect( [parentGroup,] left, top, width, height )
creates a rectangle usingwidth
byheight
. Location starts from the top-left corner of the device screen usingleft
andtop
as your coordinates of placement.display.newRoundedRect( [parentGroup,] left, top, width, height, cornerRadius )
creates a rounded rectangle usingwidth
byheight
. Location starts from the top-left corner of the device screen usingleft
andtop
as your coordinates of placement. Rounding off the corners usescornerRadius
.display.newCircle( [parentGroup,] xCenter, yCenter, radius )
creates a circle usingradius
centered atxCenter
,yCenter
.
Applying stroke width, fill color, and stroke color
All vector objects can be outlined using strokes. You can set the stroke width, fill color and stroke color.
object.strokeWidth
—Creates the stroke width in pixels.object:setFillColor( r, g, b [, a] )
—Using ther,g,b
codes between 0 and 255.a
refers to the alpha, which is optional and defaulted at 255.object:setStrokeColor( r, g, b [, a] )
—Using ther,g,b
codes between 0 and 255.a
refers to the alpha, which is optional and defaulted at 255.
The following is an example of displaying vector objects using strokes:
local rect = display.newRect(110, 100, 250, 250) rect:setFillColor(255, 255, 255) rect:setStrokeColor(45, 180, 100) rect.strokeWidth = 10

Text, text, text
In Chapter 1, Getting Started With Corona SDK, we created the Hello World application using a text display object. Let's go in detail on how text is implemented onscreen.
display.newText( [parentGroup,] string, x, y, font, size )
creates a text object using x
and y
values. There is no text color by default. In the font
parameter, apply any of the font names in the library. The size
parameter displays the size of the text. Some of the default constants can be used if you don't want to apply a font name:
native.systemFont
native.systemFontBold
Applying color and string value
The size, color, and text fields can be set or retrieved in text display objects.
object.size
—The size of the textobject:setTextColor( r, g, b [, a] )
—Using ther,g,b
codes between 0 and 255.a
refers to the alpha, which is optional and defaulted at 255object.text
—Contains the text of the textfield. It allows you to update a string value for a test object
- 24小時學會電腦組裝與維護
- 筆記本電腦使用、維護與故障排除實戰(zhàn)
- Aftershot Pro:Non-destructive photo editing and management
- 電腦常見問題與故障排除
- INSTANT Wijmo Widgets How-to
- 硬件產(chǎn)品經(jīng)理成長手記(全彩)
- 電腦軟硬件維修從入門到精通
- Mastering Adobe Photoshop Elements
- OUYA Game Development by Example
- 面向對象分析與設計(第3版)(修訂版)
- 微型計算機系統(tǒng)原理及應用:國產(chǎn)龍芯處理器的軟件和硬件集成(基礎篇)
- Internet of Things Projects with ESP32
- Spring Cloud微服務和分布式系統(tǒng)實踐
- 分布式存儲系統(tǒng):核心技術、系統(tǒng)實現(xiàn)與Go項目實戰(zhàn)
- 零基礎輕松學修電腦主板