Type Function Library display.* Return value none Revision 2017.3060 Keywords defaults, set default, color, graphics, vector objects See also display.getDefault() Shapes — Paths, Fills, Strokes display.newLine() display.newText() object.anchorX object.anchorY
Set default display values including default colors for display objects, anchor point defaults, texture wrapping settings, etc.
Any of the following are valid:
display.setDefault( key, value ) display.setDefault( key, r, g, b, alpha ) display.setDefault( key, r, g, b ) display.setDefault( key, gray ) display.setDefault( key, gray, alpha )
String. Specifies the key to set the default value for.
Numbers. Color values between 0
and 1
.
These keys specify default anchor values and anchor bounds for all display objects.
"anchorX"
— The anchor alignment along the x direction. This value is used for the value of the anchorX property in new objects. The default is 0.5
(centered along the x direction).
"anchorY"
— The anchor alignment along the y direction. This value is used for the value of the anchorY property in new objects. The default is 0.5
(centered along the y direction).
"isAnchorClamped"
— If set to false
, anchor positions along either the x or y direction are not constrained to values between 0
and 1
. In this case, setting anchor values outside of this range (negative or positive) will position the anchor outside the bounds of the display object. Default is true
.
A color key specifies which default color value to set.
"background"
— Corresponds to the default color for that the screen is cleared with. The default is initially black (0,0,0
).
"fillColor"
— Corresponds to the default fill color for vector objects like display.newRect(). The default is initially white (1,1,1
).
"strokeColor"
— Corresponds to the default stroke color for vector objects like display.newRect(). The default is initially white (1,1,1
).
"lineColor"
— Corresponds to the default color for line objects like display.newLine(). The default is initially white (1,1,1
).
"isNativeTextBoxFontSizeScaled"
— Sets the default Boolean value to be assigned to a native text box's object.isFontSizeScaled property when created via the native.newTextBox() function. This is true
by default. Set to false
to enable legacy font handling support.
"isNativeTextFieldFontSizeScaled"
— Sets the default Boolean value to be assigned to a native text field's object.isFontSizeScaled property when created via the native.newTextField() function. This is true
by default. Set to false
to enable legacy font handling support.
"preloadTextures"
— The default behavior for texture loading is to load the texture when the display object is created or when the display object uses it. Setting this value to false
will delay loading of the texture to when the object appears on screen or to when it becomes visible.
"isImageSheetSampledInsideFrame"
— Affects how image sheet frames are sampled. If set to true
, sampling is intruded by half of the source texture pixel size to avoid border artifacts. Default is false
.
"magTextureFilter"
— The default magnification sampling filter applied whenever an image is loaded by Corona. Once an image is loaded the first time, the same sampling filter will be applied for any subsequent loads of the same file. This is because textures are loaded once per file. Default value is "linear"
. Alternative value is "nearest"
.
"minTextureFilter"
— The default minification sampling filter applied whenever an image is loaded by Corona. Once an image is loaded the first time, the same sampling filter will be applied for any subsequent loads of the same file. This is because textures are loaded once per file. Default value is "linear"
. Alternative value is "nearest"
.
"textureWrapX"
— The texture wrap mode along the x direction. Once an image is loaded the first time, the same wrap mode will be applied for any subsequent loads of the same file. This is because textures are loaded once per file. Default value is "clampToEdge"
. Other values are useful for patterns and include "repeat"
or "mirroredRepeat"
.
"textureWrapY"
— The texture wrap mode along the y direction. Once an image is loaded the first time, the same wrap mode will be applied for any subsequent loads of the same file. This is because textures are loaded once per file. Default value is "clampToEdge"
. Other values are useful for patterns and include "repeat"
or "mirroredRepeat"
.
For texture wrapping ("textureWrapX"
and "textureWrapY"
), "clampToEdge"
is the only valid mode for non-power-of-two textures. To use "repeat"
or "mirroredRepeat"
, make sure the dimensions of your textures are power of two, for example 16
, 32
, 64
, 128
, 256
, etc.
When using one of the non-default wrap modes ("repeat"
or "mirroredRepeat"
), you should revert the wrap mode to default ("clampToEdge"
) when repeating fills are no longer required. For example, after filling an object with a wrapping texture, revert the wrap mode to default before proceeding with any other fill operations.
"cameraSource"
— The default behavior for a camera object fill is to use the back-facing camera. Setting this value to "front"
, will change the behavior to use the -- Set default anchor point for objects to bottom-left display.setDefault( "anchorX", 0 ) display.setDefault( "anchorY", 1 )
display.setDefault( "isAnchorClamped", false ) --display.setDefault( "isAnchorClamped", true ) local rect = display.newRect( 200, 240, 100, 100 ) rect.anchorX = -1 rect.anchorY = 1.5 transition.to( rect, { rotation=135, delay=500 } )
-- Set default fill color for vector objects to red display.setDefault( "fillColor", 1, 0, 0 ) -- Set default screen background color to blue display.setDefault( "background", 0, 0, 1 )
display.setDefault( "textureWrapX", "repeat" ) display.setDefault( "textureWrapY", "repeat" ) local x,y = display.contentCenterX, display.contentCenterY local o = display.newRect( x, y, display.contentWidth, display.contentHeight ) o.fill = { type="image", filename="fish.small.red.png" } o.fill.scaleX = 0.1 o.fill.scaleY = 0.1
if ( system.getInfo( "environment" ) ~= "simulator" ) then display.setDefault( "cameraSource", "front" ) -- Front-facing camera --display.setDefault( "cameraSource", "back" ) -- Back-facing camera end