Corona中文站

强大、易学的跨平台(iOS/Android)开发框架。QQ群1:74390406(满) 群2:221929599

导航

五分钟学会Corona(三十) - Corona API 热身
Display 库

属性:


display.contentCenterX -- (equals 0.5*display.contentWidth)

display.contentCenterY -- (equals 0.5*display.contentHeight)

display.contentScaleX -- (the ratio between content pixel and screen pixel width)

display.contentScaleY -- (the ratio between content pixel and screen pixel height)


函数:


display.setDefault( key, ... )


设置默认颜色值,用于 fill, stroke, text, line。参看Display Object颜色默认值细节(下面)。

display.newGroup( [child1 [, child2 [, child3 ... ]]] )


没有参数,这将创建一个空group,并设置父对象为root(原始行为)。

下面行为

The following behavior with arguments is EXPERIMENTAL:

When a child is passed:create a new group whose parent is the child'sset the (x,y) to be the child'sinsert the child into the new groupreset the child's transform.For subsequent child arguments, only insert into new group if each of those children has the same parent as the first one.

Display Objects

Properties:


object.contentBounds -- (equivalent to object.stageBounds which is deprecated)

object.contentWidth -- (equivalent to object.stageWidth which is deprecated)

object.contentHeight -- (equivalent to object.stageHeight which is deprecated)


Object methods:


object:toFront() -- moves object to visual front of its parent group (object.parent)

object:toBack() -- moves object to visual back of its parent group (object.parent)

object:localToContent( x, y ) -- maps x,y in object's local coordinates to content coordinates

object:contentToLocal( x, y ) -- maps x,y in content coordinates to object's local coordinates


Display Object Color Defaults

Display objects can have defaults that can be set via the following new API:


display.setDefault( key, ... )


The parameter key is a string that determines the default that gets set. The parameters that follow control what value that default is set to.

The following keys set default color values:

• "fillColor" corresponds to the default fill color for vector objects. The default is initially white.

• "strokeColor" corresponds to the default stroke color for vector objects. The default is initially white.

• "lineColor" corresponds to the default line color for line objects. The default is initially white.

• "textColor" corresponds to the default text color for text objects. The default is initially white.

There are 4 sets of valid color parameters. Here are examples for "fillColor":


display.setDefault( "fillColor", gray )

display.setDefault( "fillColor", gray, alpha )

display.setDefault( "fillColor", red, green, blue )

display.setDefault( "fillColor", red, green, blue, alpha )
<< 五分钟学会Corona(二十九) - 内存管理改进五分钟学会Corona(三十一) - 一般设计原则 >>

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最近发表

Powered By Z-Blog 1.8 Walle Build 100427 Copyright 2011-2015 BuildApp.Net. All Rights Reserved.