Options
All
  • Public
  • Public/Protected
  • All
Menu

External module core

Index

Events

ContainerStrategy

ContainerStrategy:

!en Emit when design resolution changed. !zh 当设计分辨率改变时发送。

class

ContainerStrategy

name

name: string = "ContainerStrategy"

Static EQUAL_TO_FRAME

EQUAL_TO_FRAME: any

Static PROPORTION_TO_FRAME

PROPORTION_TO_FRAME: any

Protected fixContainer

  • _fixContainer(): void

Protected setupContainer

  • setupContainer(_view: any, w: any, h: any): void

apply

  • apply(_view: any, designedResolution: any): void

postApply

  • postApply(_view: any): void

preApply

  • preApply(_view: any): void

Variables

Const ERROR_MAP_URL

ERROR_MAP_URL: "https://github.com/cocos-creator/engine/blob/3d/EngineErrorMap.md" = "https://github.com/cocos-creator/engine/blob/3d/EngineErrorMap.md"

Const ImageFormat

ImageFormat: any = cc.Enum({/*** Image Format:JPG* @property JPG* @type {Number}*/JPG: 0,/*** Image Format:PNG* @property PNG* @type {Number}*/PNG: 1,/*** Image Format:TIFF* @property TIFF* @type {Number}*/TIFF: 2,/*** Image Format:WEBP* @property WEBP* @type {Number}*/WEBP: 3,/*** Image Format:PVR* @property PVR* @type {Number}*/PVR: 4,/*** Image Format:ETC* @property ETC* @type {Number}*/ETC: 5,/*** Image Format:S3TC* @property S3TC* @type {Number}*/S3TC: 6,/*** Image Format:ATITC* @property ATITC* @type {Number}*/ATITC: 7,/*** Image Format:TGA* @property TGA* @type {Number}*/TGA: 8,/*** Image Format:RAWDATA* @property RAWDATA* @type {Number}*/RAWDATA: 9,/*** Image Format:UNKNOWN* @property UNKNOWN* @type {Number}*/UNKNOWN: 10,})

Image formats

enum

macro.ImageFormat

Const MAX_POOL_SIZE

MAX_POOL_SIZE: 20 = 20

Const SUPPORT_TEXTURE_FORMATS

SUPPORT_TEXTURE_FORMATS: string[] = ['.pkm', '.pvr', '.webp', '.jpg', '.jpeg', '.bmp', '.png']
en

Predefined constants

zh

预定义常量。

class

macro

static

Const __BrowserGetter

__BrowserGetter: BrowserGetter = new BrowserGetter()

Let _createSceneFun

_createSceneFun: any

Let _createViewFun

_createViewFun: any

Const _global

_global: any = typeof window === 'undefined' ? global : window

Let _scissorRect

_scissorRect: Rect | null = null

Const assertFormatter

assertFormatter: (Anonymous function) = getTypedFormatter('Assert')

Let ccError

ccError: log = console.log

Let ccLog

ccLog: log = console.log

Let ccWarn

ccWarn: log = console.log

Const director

director: Director = Director.instance = cc.director = new Director()

导演类。

property

director

Const errorFormatter

errorFormatter: (Anonymous function) = getTypedFormatter('Error')

Const game

game: Game = cc.game = new Game()

Const idGenerator

idGenerator: IDGenerator = new IdGenerator('Scheduler')

Const logFormatter

logFormatter: (Anonymous function) = getTypedFormatter('Log')

Let logList

logList: HTMLTextAreaElement | null = null

Const view

view: View = View.instance = cc.view = new View()
en

cc.view is the shared view object.

zh

cc.view 是全局的视图对象。

Const warnFormatter

warnFormatter: (Anonymous function) = getTypedFormatter('Warning')

Functions

resetDebugSetting

throw

  • throw(error_: any): void

assert

  • assert(value: any, message?: undefined | string, ...optionalParams: any[]): void

assertID

  • assertID(condition: boolean, id: number, ...optionalParams: any[]): void

Let ccAssert

  • ccAssert(condition: any, message?: any, ...optionalParams: any[]): void

error

  • error(message?: any, ...optionalParams: any[]): void
  • 输出错误消息到 Cocos Creator 编辑器的 Console 或运行时页面端的 Console 中。

    • 在 Cocos Creator 中,错误信息显示是红色的。
    • 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。

    Parameters

    • Optional message: any

      A JavaScript string containing zero or more substitution strings.

    • Rest ...optionalParams: any[]

      JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.

    Returns void

errorID

  • errorID(id: number, ...optionalParams: any[]): void

formatString

  • formatString(message?: any, ...optionalParams: any[]): any

getError

  • getError(errorId: any, ...param: any[]): string
  • 通过 error id 和必要的参数来获取错误信息。

    Parameters

    • errorId: any
    • Rest ...param: any[]

    Returns string

getTypedFormatter

  • getTypedFormatter(type: "Log" | "Warning" | "Error" | "Assert"): (Anonymous function)

isDisplayStats

  • isDisplayStats(): boolean

log

  • log(message?: any, ...optionalParams: any[]): void
  • 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。

    Parameters

    • Optional message: any

      A JavaScript string containing zero or more substitution strings.

    • Rest ...optionalParams: any[]

      JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.

    Returns void

logID

  • logID(id: number, ...optionalParams: any[]): void

setDisplayStats

  • setDisplayStats(displayStats: boolean): void

warn

  • warn(message?: any, ...optionalParams: any[]): void
  • 输出警告消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。

    • 在 Cocos Creator 中,警告信息显示是黄色的。
    • 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。

    Parameters

    • Optional message: any

      A JavaScript string containing zero or more substitution strings.

    • Rest ...optionalParams: any[]

      JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.

    Returns void

warnID

  • warnID(id: number, ...optionalParams: any[]): void

Object literals

Const KEY

KEY: object
en

Key map for keyboard event

zh

键盘事件的按键值。

enum

macro.KEY

example

{@link cocos/core/platform/CCCommon/KEY.js}

*

*: number = 106
en

The numeric keypad '*'

zh

数字键盘 *

property

*

type

{Number}

readonly

+

+: number = 107
en

The numeric keypad '+'

zh

数字键盘 +

property

+

type

{Number}

readonly

,

,: number = 188
en

The ',' key.

zh

逗号键

property

,

type

{Number}

readonly

-

-: number = 109
en

The numeric keypad '-'

zh

数字键盘 -

property

-

type

{Number}

readonly

.

.: number = 190
en

The '.' key.

zh

句号键

property

.

type

{Number}

readonly

/

/: number = 111
en

The numeric keypad '/'

zh

数字键盘 /

property

/

type

{Number}

readonly

0

0: number = 48
en

The '0' key on the top of the alphanumeric keyboard.

zh

字母键盘上的 0 键

property

0

type

{Number}

readonly

1

1: number = 49
en

The '1' key on the top of the alphanumeric keyboard.

zh

字母键盘上的 1 键

property

1

type

{Number}

readonly

2

2: number = 50
en

The '2' key on the top of the alphanumeric keyboard.

zh

字母键盘上的 2 键

property

2

type

{Number}

readonly

3

3: number = 51
en

The '3' key on the top of the alphanumeric keyboard.

zh

字母键盘上的 3 键

property

3

type

{Number}

readonly

4

4: number = 52
en

The '4' key on the top of the alphanumeric keyboard.

zh

字母键盘上的 4 键

property

4

type

{Number}

readonly

5

5: number = 53
en

The '5' key on the top of the alphanumeric keyboard.

zh

字母键盘上的 5 键

property

5

type

{Number}

readonly

6

6: number = 54
en

The '6' key on the top of the alphanumeric keyboard.

zh

字母键盘上的 6 键

property

6

type

{Number}

readonly

7

7: number = 55
en

The '7' key on the top of the alphanumeric keyboard.

zh

字母键盘上的 7 键

property

7

type

{Number}

readonly

8

8: number = 56
en

The '8' key on the top of the alphanumeric keyboard.

zh

字母键盘上的 8 键

property

8

type

{Number}

readonly

9

9: number = 57
en

The '9' key on the top of the alphanumeric keyboard.

zh

字母键盘上的 9 键

property

9

type

{Number}

readonly

;

;: number = 186
en

The ';' key.

zh

分号键

property

;

type

{Number}

readonly

=

=: number = 187
en

The '=' key.

zh

等于号键

property

=

type

{Number}

readonly

Delete

Delete: number = 46
en

The Delete key

zh

删除键

property

Delete

type

{Number}

readonly

[

[: number = 219
en

The '[' key

zh

按键 [

property

[

type

{Number}

readonly

]

]: number = 221
en

The ']' key

zh

按键 ]

property

]

type

{Number}

readonly

a

a: number = 65
en

The a key

zh

A 键

property

a

type

{Number}

readonly

alt

alt: number = 18
en

The alt key

zh

Alt 键

property

alt

type

{Number}

readonly

b

b: number = 66
en

The b key

zh

B 键

property

b

type

{Number}

readonly

back

back: number = 6
en

The back key

zh

返回键

property

back

type

{Number}

readonly

backslash

backslash: number = 220
en

The '' key

zh

反斜杠键

property

backslash

type

{Number}

readonly

backspace

backspace: number = 8
en

The backspace key

zh

退格键

property

backspace

type

{Number}

readonly

c

c: number = 67
en

The c key

zh

C 键

property

c

type

{Number}

readonly

capslock

capslock: number = 20
en

The caps lock key

zh

大写锁定键

property

capslock

type

{Number}

readonly

closebracket

closebracket: number = 221
en

The ']' key

zh

按键 ]

property

closebracket

type

{Number}

readonly

comma

comma: number = 188
en

The ',' key.

zh

逗号键

property

comma

type

{Number}

readonly

ctrl

ctrl: number = 17
en

The ctrl key

zh

Ctrl 键

property

ctrl

type

{Number}

readonly

d

d: number = 68
en

The d key

zh

D 键

property

d

type

{Number}

readonly

dash

dash: number = 189
en

The dash '-' key.

zh

中划线键

property

dash

type

{Number}

readonly

down

down: number = 40
en

The down key

zh

向下箭头键

property

down

type

{Number}

readonly

dpadCenter

dpadCenter: number = 1005
en

The dpad center key

zh

导航键 确定键

property

dpadCenter

type

{Number}

readonly

dpadDown

dpadDown: number = 1004
en

The dpad down key

zh

导航键 向下

property

dpadDown

type

{Number}

readonly

dpadLeft

dpadLeft: number = 1000
en

The dpad left key

zh

导航键 向左

property

dpadLeft

type

{Number}

readonly

dpadRight

dpadRight: number = 1001
en

The dpad right key

zh

导航键 向右

property

dpadRight

type

{Number}

readonly

dpadUp

dpadUp: number = 1003
en

The dpad up key

zh

导航键 向上

property

dpadUp

type

{Number}

readonly

e

e: number = 69
en

The e key

zh

E 键

property

e

type

{Number}

readonly

end

end: number = 35
en

The end key

zh

结束键

property

end

type

{Number}

readonly

enter

enter: number = 13
en

The enter key

zh

回车键

property

enter

type

{Number}

readonly

equal

equal: number = 187
en

The '=' key.

zh

等于号键

property

equal

type

{Number}

readonly

escape

escape: number = 27
en

The esc key

zh

ESC 键

property

escape

type

{Number}

readonly

f

f: number = 70
en

The f key

zh

F 键

property

f

type

{Number}

readonly

f1

f1: number = 112
en

The F1 function key

zh

F1 功能键

property

f1

type

{Number}

readonly

f10

f10: number = 121
en

The F10 function key

zh

F10 功能键

property

f10

type

{Number}

readonly

f11

f11: number = 122
en

The F11 function key

zh

F11 功能键

property

f11

type

{Number}

readonly

f12

f12: number = 123
en

The F12 function key

zh

F12 功能键

property

f12

type

{Number}

readonly

f2

f2: number = 113
en

The F2 function key

zh

F2 功能键

property

f2

type

{Number}

readonly

f3

f3: number = 114
en

The F3 function key

zh

F3 功能键

property

f3

type

{Number}

readonly

f4

f4: number = 115
en

The F4 function key

zh

F4 功能键

property

f4

type

{Number}

readonly

f5

f5: number = 116
en

The F5 function key

zh

F5 功能键

property

f5

type

{Number}

readonly

f6

f6: number = 117
en

The F6 function key

zh

F6 功能键

property

f6

type

{Number}

readonly

f7

f7: number = 118
en

The F7 function key

zh

F7 功能键

property

f7

type

{Number}

readonly

f8

f8: number = 119
en

The F8 function key

zh

F8 功能键

property

f8

type

{Number}

readonly

f9

f9: number = 120
en

The F9 function key

zh

F9 功能键

property

f9

type

{Number}

readonly

forwardslash

forwardslash: number = 191
en

The forward slash key

zh

正斜杠键

property

forwardslash

type

{Number}

readonly

g

g: number = 71
en

The g key

zh

G 键

property

g

type

{Number}

readonly

grave

grave: number = 192
en

The grave key

zh

按键 `

property

grave

type

{Number}

readonly

h

h: number = 72
en

The h key

zh

H 键

property

h

type

{Number}

readonly

home

home: number = 36
en

The home key

zh

主菜单键

property

home

type

{Number}

readonly

i

i: number = 73
en

The i key

zh

I 键

property

i

type

{Number}

readonly

insert

insert: number = 45
en

The insert key

zh

插入键

property

insert

type

{Number}

readonly

j

j: number = 74
en

The j key

zh

J 键

property

j

type

{Number}

readonly

k

k: number = 75
en

The k key

zh

K 键

property

k

type

{Number}

readonly

l

l: number = 76
en

The l key

zh

L 键

property

l

type

{Number}

readonly

left

left: number = 37
en

The left key

zh

向左箭头键

property

left

type

{Number}

readonly

m

m: number = 77
en

The m key

zh

M 键

property

m

type

{Number}

readonly

menu

menu: number = 18
en

The menu key

zh

菜单键

property

menu

type

{Number}

readonly

n

n: number = 78
en

The n key

zh

N 键

property

n

type

{Number}

readonly

none

none: number = 0
en

None

zh

没有分配

property

none

type

{Number}

readonly

num0

num0: number = 96
en

The numeric keypad 0

zh

数字键盘 0

property

num0

type

{Number}

readonly

num1

num1: number = 97
en

The numeric keypad 1

zh

数字键盘 1

property

num1

type

{Number}

readonly

num2

num2: number = 98
en

The numeric keypad 2

zh

数字键盘 2

property

num2

type

{Number}

readonly

num3

num3: number = 99
en

The numeric keypad 3

zh

数字键盘 3

property

num3

type

{Number}

readonly

num4

num4: number = 100
en

The numeric keypad 4

zh

数字键盘 4

property

num4

type

{Number}

readonly

num5

num5: number = 101
en

The numeric keypad 5

zh

数字键盘 5

property

num5

type

{Number}

readonly

num6

num6: number = 102
en

The numeric keypad 6

zh

数字键盘 6

property

num6

type

{Number}

readonly

num7

num7: number = 103
en

The numeric keypad 7

zh

数字键盘 7

property

num7

type

{Number}

readonly

num8

num8: number = 104
en

The numeric keypad 8

zh

数字键盘 8

property

num8

type

{Number}

readonly

num9

num9: number = 105
en

The numeric keypad 9

zh

数字键盘 9

property

num9

type

{Number}

readonly

numdel

numdel: number = 110
en

The numeric keypad 'delete'

zh

数字键盘删除键

property

numdel

type

{Number}

readonly

numlock

numlock: number = 144
en

The numlock key

zh

数字锁定键

property

numlock

type

{Number}

readonly

o

o: number = 79
en

The o key

zh

O 键

property

o

type

{Number}

readonly

openbracket

openbracket: number = 219
en

The '[' key

zh

按键 [

property

openbracket

type

{Number}

readonly

p

p: number = 80
en

The p key

zh

P 键

property

p

type

{Number}

readonly

pagedown

pagedown: number = 34
en

The page down key

zh

向下翻页键

property

pagedown

type

{Number}

readonly

pageup

pageup: number = 33
en

The page up key

zh

向上翻页键

property

pageup

type

{Number}

readonly

pause

pause: number = 19
en

The pause key

zh

暂停键

property

pause

type

{Number}

readonly

period

period: number = 190
en

The '.' key

zh

句号键

property

period

type

{Number}

readonly

q

q: number = 81
en

The q key

zh

Q 键

property

q

type

{Number}

readonly

quote

quote: number = 222
en

The quote key

zh

单引号键

property

quote

type

{Number}

readonly

r

r: number = 82
en

The r key

zh

R 键

property

r

type

{Number}

readonly

right

right: number = 39
en

The right key

zh

向右箭头键

property

right

type

{Number}

readonly

s

s: number = 83
en

The s key

zh

S 键

property

s

type

{Number}

readonly

scrolllock

scrolllock: number = 145
en

The scroll lock key

zh

滚动锁定键

property

scrolllock

type

{Number}

readonly

select

select: number = 41
en

The select key

zh

Select 键

property

select

type

{Number}

readonly

semicolon

semicolon: number = 186
en

The ';' key.

zh

分号键

property

semicolon

type

{Number}

readonly

shift

shift: number = 16
en

The shift key

zh

Shift 键

property

shift

type

{Number}

readonly

space

space: number = 32
en

The space key

zh

空格键

property

space

type

{Number}

readonly

t

t: number = 84
en

The t key

zh

T 键

property

t

type

{Number}

readonly

tab

tab: number = 9
en

The tab key

zh

Tab 键

property

tab

type

{Number}

readonly

u

u: number = 85
en

The u key

zh

U 键

property

u

type

{Number}

readonly

up

up: number = 38
en

The up key

zh

向上箭头键

property

up

type

{Number}

readonly

v

v: number = 86
en

The v key

zh

V 键

property

v

type

{Number}

readonly

w

w: number = 87
en

The w key

zh

W 键

property

w

type

{Number}

readonly

x

x: number = 88
en

The x key

zh

X 键

property

x

type

{Number}

readonly

y

y: number = 89
en

The y key

zh

Y 键

property

y

type

{Number}

readonly

z

z: number = 90
en

The z key

zh

Z 键

property

z

type

{Number}

readonly

Const macro

macro: object
module

macro

BATCH_VERTEX_COUNT

BATCH_VERTEX_COUNT: number = 20000
en

The maximum vertex count for a single batched draw call.

zh

最大可以被单次批处理渲染的顶点数量。

property

{Number} BATCH_VERTEX_COUNT

CLEANUP_IMAGE_CACHE

CLEANUP_IMAGE_CACHE: boolean = false
en

Whether or not clear dom Image object cache after uploading to gl texture. Concretely, we are setting image.src to empty string to release the cache. Normally you don't need to enable this option, because on web the Image object doesn't consume too much memory. But on Wechat Game platform, the current version cache decoded data in Image object, which has high memory usage. So we enabled this option by default on Wechat, so that we can release Image cache immediately after uploaded to GPU.

zh

是否在将贴图上传至 GPU 之后删除 DOM Image 缓存。 具体来说,我们通过设置 image.src 为空字符串来释放这部分内存。 正常情况下,你不需要开启这个选项,因为在 web 平台,Image 对象所占用的内存很小。 但是在微信小游戏平台的当前版本,Image 对象会缓存解码后的图片数据,它所占用的内存空间很大。 所以我们在微信平台默认开启了这个选项,这样我们就可以在上传 GL 贴图之后立即释放 Image 对象的内存,避免过高的内存占用。

property

{Boolean} CLEANUP_IMAGE_CACHE

default

false

DEG

DEG: number = 180 / Math.PI

One degree

property

DEG

type

{Number}

DENSITYDPI_DEVICE

DENSITYDPI_DEVICE: string = "device-dpi"

DENSITYDPI_HIGH

DENSITYDPI_HIGH: string = "high-dpi"

DENSITYDPI_LOW

DENSITYDPI_LOW: string = "low-dpi"

DENSITYDPI_MEDIUM

DENSITYDPI_MEDIUM: string = "medium-dpi"

DIRECTOR_STATS_POSITION

DIRECTOR_STATS_POSITION: Vec2 = new Vec2(0, 0)

Position of the FPS (Default: 0,0 (bottom-left corner))
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h

property

{Vec2} DIRECTOR_STATS_POSITION

DOWNLOAD_MAX_CONCURRENT

DOWNLOAD_MAX_CONCURRENT: number = 64
en

The max concurrent task number for the downloader

zh

下载任务的最大并发数限制,在安卓平台部分机型或版本上可能需要限制在较低的水平

property

{Number} DOWNLOAD_MAX_CONCURRENT

default

64

ENABLE_CULLING

ENABLE_CULLING: boolean = false
en

Whether or not enable auto culling. This feature have been removed in v2.0 new renderer due to overall performance consumption. We have no plan currently to re-enable auto culling. If your game have more dynamic objects, we suggest to disable auto culling. If your game have more static objects, we suggest to enable auto culling.

zh

是否开启自动裁减功能,开启裁减功能将会把在屏幕外的物体从渲染队列中去除掉。 这个功能在 v2.0 的新渲染器中被移除了,因为它在大多数游戏中所带来的损耗要高于性能的提升,目前我们没有计划重新支持自动裁剪。 如果游戏中的动态物体比较多的话,建议将此选项关闭。 如果游戏中的静态物体比较多的话,建议将此选项打开。

property

{Boolean} ENABLE_CULLING

deprecated

since v2.0

default

false

ENABLE_MULTI_TOUCH

ENABLE_MULTI_TOUCH: boolean = true
en

Whether to enable multi-touch.

zh

是否开启多点触摸

property

{Boolean} ENABLE_MULTI_TOUCH

default

true

ENABLE_STACKABLE_ACTIONS

ENABLE_STACKABLE_ACTIONS: boolean = true

If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked.
If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions.
If disabled, only the last run action will take effect.

property

{Number} ENABLE_STACKABLE_ACTIONS

ENABLE_TILEDMAP_CULLING

ENABLE_TILEDMAP_CULLING: boolean = true
en

Whether or not enabled tiled map auto culling. If you set the TiledMap skew or rotation, then need to manually disable this, otherwise, the rendering will be wrong.

zh

是否开启瓦片地图的自动裁减功能。瓦片地图如果设置了 skew, rotation 的话,需要手动关闭,否则渲染会出错。

property

{Boolean} ENABLE_TILEDMAP_CULLING

default

true

ENABLE_TRANSPARENT_CANVAS

ENABLE_TRANSPARENT_CANVAS: boolean = false
en

Boolean that indicates if the canvas contains an alpha channel, default sets to false for better performance. Though if you want to make your canvas background transparent and show other dom elements at the background, you can set it to true before cc.game.run. Web only.

zh

用于设置 Canvas 背景是否支持 alpha 通道,默认为 false,这样可以有更高的性能表现。 如果你希望 Canvas 背景是透明的,并显示背后的其他 DOM 元素,你可以在 cc.game.run 之前将这个值设为 true。 仅支持 Web

property

{Boolean} ENABLE_TRANSPARENT_CANVAS

default

false

ENABLE_WEBGL_ANTIALIAS

ENABLE_WEBGL_ANTIALIAS: boolean = false
en

Boolean that indicates if the WebGL context is created with antialias option turned on, default value is false. Set it to true could make your game graphics slightly smoother, like texture hard edges when rotated. Whether to use this really depend on your game design and targeted platform, device with retina display usually have good detail on graphics with or without this option, you probably don't want antialias if your game style is pixel art based. Also, it could have great performance impact with some browser / device using software MSAA. You can set it to true before cc.game.run. Web only.

zh

用于设置在创建 WebGL Context 时是否开启抗锯齿选项,默认值是 false。 将这个选项设置为 true 会让你的游戏画面稍稍平滑一些,比如旋转硬边贴图时的锯齿。是否开启这个选项很大程度上取决于你的游戏和面向的平台。 在大多数拥有 retina 级别屏幕的设备上用户往往无法区分这个选项带来的变化;如果你的游戏选择像素艺术风格,你也多半不会想开启这个选项。 同时,在少部分使用软件级别抗锯齿算法的设备或浏览器上,这个选项会对性能产生比较大的影响。 你可以在 cc.game.run 之前设置这个值,否则它不会生效。 仅支持 Web

property

{Boolean} ENABLE_WEBGL_ANTIALIAS

default

false

FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX

FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX: boolean = true

If enabled, the texture coordinates will be calculated by using this formula:
- texCoord.left = (rect.x*2+1) / (texture.wide*2);
- texCoord.right = texCoord.left + (rect.width*2-2)/(texture.wide*2);

The same for bottom and top.

This formula prevents artifacts by using 99% of the texture.
The "correct" way to prevent artifacts is by expand the texture's border with the same color by 1 pixel

Affected component:
- cc.TMXLayer

Enabled by default. To disabled set it to 0.
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h

property

{Number} FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX

FLT_EPSILON

FLT_EPSILON: number = 1.192092896e-7
property

FLT_EPSILON

type

{Number}

ImageFormat

ImageFormat: any

KEY

KEY: object

Type declaration

  • *: number
    en

    The numeric keypad '*'

    zh

    数字键盘 *

    property

    *

    type

    {Number}

    readonly
  • +: number
    en

    The numeric keypad '+'

    zh

    数字键盘 +

    property

    +

    type

    {Number}

    readonly
  • ,: number
    en

    The ',' key.

    zh

    逗号键

    property

    ,

    type

    {Number}

    readonly
  • -: number
    en

    The numeric keypad '-'

    zh

    数字键盘 -

    property

    -

    type

    {Number}

    readonly
  • .: number
    en

    The '.' key.

    zh

    句号键

    property

    .

    type

    {Number}

    readonly
  • /: number
    en

    The numeric keypad '/'

    zh

    数字键盘 /

    property

    /

    type

    {Number}

    readonly
  • 0: number
    en

    The '0' key on the top of the alphanumeric keyboard.

    zh

    字母键盘上的 0 键

    property

    0

    type

    {Number}

    readonly
  • 1: number
    en

    The '1' key on the top of the alphanumeric keyboard.

    zh

    字母键盘上的 1 键

    property

    1

    type

    {Number}

    readonly
  • 2: number
    en

    The '2' key on the top of the alphanumeric keyboard.

    zh

    字母键盘上的 2 键

    property

    2

    type

    {Number}

    readonly
  • 3: number
    en

    The '3' key on the top of the alphanumeric keyboard.

    zh

    字母键盘上的 3 键

    property

    3

    type

    {Number}

    readonly
  • 4: number
    en

    The '4' key on the top of the alphanumeric keyboard.

    zh

    字母键盘上的 4 键

    property

    4

    type

    {Number}

    readonly
  • 5: number
    en

    The '5' key on the top of the alphanumeric keyboard.

    zh

    字母键盘上的 5 键

    property

    5

    type

    {Number}

    readonly
  • 6: number
    en

    The '6' key on the top of the alphanumeric keyboard.

    zh

    字母键盘上的 6 键

    property

    6

    type

    {Number}

    readonly
  • 7: number
    en

    The '7' key on the top of the alphanumeric keyboard.

    zh

    字母键盘上的 7 键

    property

    7

    type

    {Number}

    readonly
  • 8: number
    en

    The '8' key on the top of the alphanumeric keyboard.

    zh

    字母键盘上的 8 键

    property

    8

    type

    {Number}

    readonly
  • 9: number
    en

    The '9' key on the top of the alphanumeric keyboard.

    zh

    字母键盘上的 9 键

    property

    9

    type

    {Number}

    readonly
  • ;: number
    en

    The ';' key.

    zh

    分号键

    property

    ;

    type

    {Number}

    readonly
  • =: number
    en

    The '=' key.

    zh

    等于号键

    property

    =

    type

    {Number}

    readonly
  • Delete: number
    en

    The Delete key

    zh

    删除键

    property

    Delete

    type

    {Number}

    readonly
  • [: number
    en

    The '[' key

    zh

    按键 [

    property

    [

    type

    {Number}

    readonly
  • ]: number
    en

    The ']' key

    zh

    按键 ]

    property

    ]

    type

    {Number}

    readonly
  • a: number
    en

    The a key

    zh

    A 键

    property

    a

    type

    {Number}

    readonly
  • alt: number
    en

    The alt key

    zh

    Alt 键

    property

    alt

    type

    {Number}

    readonly
  • b: number
    en

    The b key

    zh

    B 键

    property

    b

    type

    {Number}

    readonly
  • back: number
    en

    The back key

    zh

    返回键

    property

    back

    type

    {Number}

    readonly
  • backslash: number
    en

    The '' key

    zh

    反斜杠键

    property

    backslash

    type

    {Number}

    readonly
  • backspace: number
    en

    The backspace key

    zh

    退格键

    property

    backspace

    type

    {Number}

    readonly
  • c: number
    en

    The c key

    zh

    C 键

    property

    c

    type

    {Number}

    readonly
  • capslock: number
    en

    The caps lock key

    zh

    大写锁定键

    property

    capslock

    type

    {Number}

    readonly
  • closebracket: number
    en

    The ']' key

    zh

    按键 ]

    property

    closebracket

    type

    {Number}

    readonly
  • comma: number
    en

    The ',' key.

    zh

    逗号键

    property

    comma

    type

    {Number}

    readonly
  • ctrl: number
    en

    The ctrl key

    zh

    Ctrl 键

    property

    ctrl

    type

    {Number}

    readonly
  • d: number
    en

    The d key

    zh

    D 键

    property

    d

    type

    {Number}

    readonly
  • dash: number
    en

    The dash '-' key.

    zh

    中划线键

    property

    dash

    type

    {Number}

    readonly
  • down: number
    en

    The down key

    zh

    向下箭头键

    property

    down

    type

    {Number}

    readonly
  • dpadCenter: number
    en

    The dpad center key

    zh

    导航键 确定键

    property

    dpadCenter

    type

    {Number}

    readonly
  • dpadDown: number
    en

    The dpad down key

    zh

    导航键 向下

    property

    dpadDown

    type

    {Number}

    readonly
  • dpadLeft: number
    en

    The dpad left key

    zh

    导航键 向左

    property

    dpadLeft

    type

    {Number}

    readonly
  • dpadRight: number
    en

    The dpad right key

    zh

    导航键 向右

    property

    dpadRight

    type

    {Number}

    readonly
  • dpadUp: number
    en

    The dpad up key

    zh

    导航键 向上

    property

    dpadUp

    type

    {Number}

    readonly
  • e: number
    en

    The e key

    zh

    E 键

    property

    e

    type

    {Number}

    readonly
  • end: number
    en

    The end key

    zh

    结束键

    property

    end

    type

    {Number}

    readonly
  • enter: number
    en

    The enter key

    zh

    回车键

    property

    enter

    type

    {Number}

    readonly
  • equal: number
    en

    The '=' key.

    zh

    等于号键

    property

    equal

    type

    {Number}

    readonly
  • escape: number
    en

    The esc key

    zh

    ESC 键

    property

    escape

    type

    {Number}

    readonly
  • f: number
    en

    The f key

    zh

    F 键

    property

    f

    type

    {Number}

    readonly
  • f1: number
    en

    The F1 function key

    zh

    F1 功能键

    property

    f1

    type

    {Number}

    readonly
  • f10: number
    en

    The F10 function key

    zh

    F10 功能键

    property

    f10

    type

    {Number}

    readonly
  • f11: number
    en

    The F11 function key

    zh

    F11 功能键

    property

    f11

    type

    {Number}

    readonly
  • f12: number
    en

    The F12 function key

    zh

    F12 功能键

    property

    f12

    type

    {Number}

    readonly
  • f2: number
    en

    The F2 function key

    zh

    F2 功能键

    property

    f2

    type

    {Number}

    readonly
  • f3: number
    en

    The F3 function key

    zh

    F3 功能键

    property

    f3

    type

    {Number}

    readonly
  • f4: number
    en

    The F4 function key

    zh

    F4 功能键

    property

    f4

    type

    {Number}

    readonly
  • f5: number
    en

    The F5 function key

    zh

    F5 功能键

    property

    f5

    type

    {Number}

    readonly
  • f6: number
    en

    The F6 function key

    zh

    F6 功能键

    property

    f6

    type

    {Number}

    readonly
  • f7: number
    en

    The F7 function key

    zh

    F7 功能键

    property

    f7

    type

    {Number}

    readonly
  • f8: number
    en

    The F8 function key

    zh

    F8 功能键

    property

    f8

    type

    {Number}

    readonly
  • f9: number
    en

    The F9 function key

    zh

    F9 功能键

    property

    f9

    type

    {Number}

    readonly
  • forwardslash: number
    en

    The forward slash key

    zh

    正斜杠键

    property

    forwardslash

    type

    {Number}

    readonly
  • g: number
    en

    The g key

    zh

    G 键

    property

    g

    type

    {Number}

    readonly
  • grave: number
    en

    The grave key

    zh

    按键 `

    property

    grave

    type

    {Number}

    readonly
  • h: number
    en

    The h key

    zh

    H 键

    property

    h

    type

    {Number}

    readonly
  • home: number
    en

    The home key

    zh

    主菜单键

    property

    home

    type

    {Number}

    readonly
  • i: number
    en

    The i key

    zh

    I 键

    property

    i

    type

    {Number}

    readonly
  • insert: number
    en

    The insert key

    zh

    插入键

    property

    insert

    type

    {Number}

    readonly
  • j: number
    en

    The j key

    zh

    J 键

    property

    j

    type

    {Number}

    readonly
  • k: number
    en

    The k key

    zh

    K 键

    property

    k

    type

    {Number}

    readonly
  • l: number
    en

    The l key

    zh

    L 键

    property

    l

    type

    {Number}

    readonly
  • left: number
    en

    The left key

    zh

    向左箭头键

    property

    left

    type

    {Number}

    readonly
  • m: number
    en

    The m key

    zh

    M 键

    property

    m

    type

    {Number}

    readonly
  • menu: number
    en

    The menu key

    zh

    菜单键

    property

    menu

    type

    {Number}

    readonly
  • n: number
    en

    The n key

    zh

    N 键

    property

    n

    type

    {Number}

    readonly
  • none: number
    en

    None

    zh

    没有分配

    property

    none

    type

    {Number}

    readonly
  • num0: number
    en

    The numeric keypad 0

    zh

    数字键盘 0

    property

    num0

    type

    {Number}

    readonly
  • num1: number
    en

    The numeric keypad 1

    zh

    数字键盘 1

    property

    num1

    type

    {Number}

    readonly
  • num2: number
    en

    The numeric keypad 2

    zh

    数字键盘 2

    property

    num2

    type

    {Number}

    readonly
  • num3: number
    en

    The numeric keypad 3

    zh

    数字键盘 3

    property

    num3

    type

    {Number}

    readonly
  • num4: number
    en

    The numeric keypad 4

    zh

    数字键盘 4

    property

    num4

    type

    {Number}

    readonly
  • num5: number
    en

    The numeric keypad 5

    zh

    数字键盘 5

    property

    num5

    type

    {Number}

    readonly
  • num6: number
    en

    The numeric keypad 6

    zh

    数字键盘 6

    property

    num6

    type

    {Number}

    readonly
  • num7: number
    en

    The numeric keypad 7

    zh

    数字键盘 7

    property

    num7

    type

    {Number}

    readonly
  • num8: number
    en

    The numeric keypad 8

    zh

    数字键盘 8

    property

    num8

    type

    {Number}

    readonly
  • num9: number
    en

    The numeric keypad 9

    zh

    数字键盘 9

    property

    num9

    type

    {Number}

    readonly
  • numdel: number
    en

    The numeric keypad 'delete'

    zh

    数字键盘删除键

    property

    numdel

    type

    {Number}

    readonly
  • numlock: number
    en

    The numlock key

    zh

    数字锁定键

    property

    numlock

    type

    {Number}

    readonly
  • o: number
    en

    The o key

    zh

    O 键

    property

    o

    type

    {Number}

    readonly
  • openbracket: number
    en

    The '[' key

    zh

    按键 [

    property

    openbracket

    type

    {Number}

    readonly
  • p: number
    en

    The p key

    zh

    P 键

    property

    p

    type

    {Number}

    readonly
  • pagedown: number
    en

    The page down key

    zh

    向下翻页键

    property

    pagedown

    type

    {Number}

    readonly
  • pageup: number
    en

    The page up key

    zh

    向上翻页键

    property

    pageup

    type

    {Number}

    readonly
  • pause: number
    en

    The pause key

    zh

    暂停键

    property

    pause

    type

    {Number}

    readonly
  • period: number
    en

    The '.' key

    zh

    句号键

    property

    period

    type

    {Number}

    readonly
  • q: number
    en

    The q key

    zh

    Q 键

    property

    q

    type

    {Number}

    readonly
  • quote: number
    en

    The quote key

    zh

    单引号键

    property

    quote

    type

    {Number}

    readonly
  • r: number
    en

    The r key

    zh

    R 键

    property

    r

    type

    {Number}

    readonly
  • right: number
    en

    The right key

    zh

    向右箭头键

    property

    right

    type

    {Number}

    readonly
  • s: number
    en

    The s key

    zh

    S 键

    property

    s

    type

    {Number}

    readonly
  • scrolllock: number
    en

    The scroll lock key

    zh

    滚动锁定键

    property

    scrolllock

    type

    {Number}

    readonly
  • select: number
    en

    The select key

    zh

    Select 键

    property

    select

    type

    {Number}

    readonly
  • semicolon: number
    en

    The ';' key.

    zh

    分号键

    property

    semicolon

    type

    {Number}

    readonly
  • shift: number
    en

    The shift key

    zh

    Shift 键

    property

    shift

    type

    {Number}

    readonly
  • space: number
    en

    The space key

    zh

    空格键

    property

    space

    type

    {Number}

    readonly
  • t: number
    en

    The t key

    zh

    T 键

    property

    t

    type

    {Number}

    readonly
  • tab: number
    en

    The tab key

    zh

    Tab 键

    property

    tab

    type

    {Number}

    readonly
  • u: number
    en

    The u key

    zh

    U 键

    property

    u

    type

    {Number}

    readonly
  • up: number
    en

    The up key

    zh

    向上箭头键

    property

    up

    type

    {Number}

    readonly
  • v: number
    en

    The v key

    zh

    V 键

    property

    v

    type

    {Number}

    readonly
  • w: number
    en

    The w key

    zh

    W 键

    property

    w

    type

    {Number}

    readonly
  • x: number
    en

    The x key

    zh

    X 键

    property

    x

    type

    {Number}

    readonly
  • y: number
    en

    The y key

    zh

    Y 键

    property

    y

    type

    {Number}

    readonly
  • z: number
    en

    The z key

    zh

    Z 键

    property

    z

    type

    {Number}

    readonly

MAX_ZINDEX

MAX_ZINDEX: number = Math.pow(2, 15) - 1

Maximum z index value for node

property

MAX_ZINDEX

type

{Number}

MIN_ZINDEX

MIN_ZINDEX: number = -Math.pow(2, 15)

Minimum z index value for node

property

MIN_ZINDEX

type

{Number}

ORIENTATION_AUTO

ORIENTATION_AUTO: number = 3

Oriented automatically

property

ORIENTATION_AUTO

type

{Number}

ORIENTATION_LANDSCAPE

ORIENTATION_LANDSCAPE: number = 2

Oriented horizontally

property

ORIENTATION_LANDSCAPE

type

{Number}

ORIENTATION_PORTRAIT

ORIENTATION_PORTRAIT: number = 1

Oriented vertically

property

ORIENTATION_PORTRAIT

type

{Number}

RAD

RAD: number = Math.PI / 180

PI / 180

property

RAD

type

{Number}

REPEAT_FOREVER

REPEAT_FOREVER: number = (Number.MAX_VALUE - 1)
property

REPEAT_FOREVER

type

{Number}

SHOW_MESH_WIREFRAME

SHOW_MESH_WIREFRAME: boolean = false
en

Whether or not show mesh wire frame.

zh

是否显示网格的线框。

property

{Boolean} SHOW_MESH_WIREFRAME

default

false

SUPPORT_TEXTURE_FORMATS

SUPPORT_TEXTURE_FORMATS: string[]

!en The image format supported by the engine defaults, and the supported formats may differ in different build platforms and device types. Currently all platform and device support ['.webp', '.jpg', '.jpeg', '.bmp', '.png'], ios mobile platform !zh 引擎默认支持的图片格式,支持的格式可能在不同的构建平台和设备类型上有所差别。 目前所有平台和设备支持的格式有 ['.webp', '.jpg', '.jpeg', '.bmp', '.png']. The iOS mobile platform also supports the PVR format。

property

{[String]} SUPPORT_TEXTURE_FORMATS

TOUCH_TIMEOUT

TOUCH_TIMEOUT: number = 5000
en

The timeout to determine whether a touch is no longer active and should be removed. The reason to add this timeout is due to an issue in X5 browser core, when X5 is presented in wechat on Android, if a touch is glissed from the bottom up, and leave the page area, no touch cancel event is triggered, and the touch will be considered active forever. After multiple times of this action, our maximum touches number will be reached and all new touches will be ignored. So this new mechanism can remove the touch that should be inactive if it's not updated during the last 5000 milliseconds. Though it might remove a real touch if it's just not moving for the last 5 seconds which is not easy with the sensibility of mobile touch screen. You can modify this value to have a better behavior if you find it's not enough.

zh

用于甄别一个触点对象是否已经失效并且可以被移除的延时时长 添加这个时长的原因是 X5 内核在微信浏览器中出现的一个 bug。 在这个环境下,如果用户将一个触点从底向上移出页面区域,将不会触发任何 touch cancel 或 touch end 事件,而这个触点会被永远当作停留在页面上的有效触点。 重复这样操作几次之后,屏幕上的触点数量将达到我们的事件系统所支持的最高触点数量,之后所有的触摸事件都将被忽略。 所以这个新的机制可以在触点在一定时间内没有任何更新的情况下视为失效触点并从事件系统中移除。 当然,这也可能移除一个真实的触点,如果用户的触点真的在一定时间段内完全没有移动(这在当前手机屏幕的灵敏度下会很难)。 你可以修改这个值来获得你需要的效果,默认值是 5000 毫秒。

property

{Number} TOUCH_TIMEOUT

Const screen

screen: object

The fullscreen API provides an easy way for web content to be presented using the user's entire screen. It's invalid on safari, QQbrowser and android browser

class

screen

_fn

_fn: any = null as any

_fnMap

_fnMap: string[][] = [['requestFullscreen','exitFullscreen','fullscreenchange','fullscreenEnabled','fullscreenElement',],['requestFullScreen','exitFullScreen','fullScreenchange','fullScreenEnabled','fullScreenElement',],['webkitRequestFullScreen','webkitCancelFullScreen','webkitfullscreenchange','webkitIsFullScreen','webkitCurrentFullScreenElement',],['mozRequestFullScreen','mozCancelFullScreen','mozfullscreenchange','mozFullScreen','mozFullScreenElement',],['msRequestFullscreen','msExitFullscreen','MSFullscreenChange','msFullscreenEnabled','msFullscreenElement',],]

_preOnFullScreenChange

_preOnFullScreenChange: any = null as any

_supportsFullScreen

_supportsFullScreen: boolean = false

_touchEvent

_touchEvent: string = ""

autoFullScreen

  • autoFullScreen(element: any, onFullScreenChange: any): void
  • Automatically request full screen with a touch/click event

    method

    autoFullScreen

    Parameters

    • element: any
    • onFullScreenChange: any

    Returns void

exitFullScreen

  • exitFullScreen(): any

fullScreen

  • fullScreen(): boolean

init

  • init(): void

requestFullScreen

  • requestFullScreen(element: any, onFullScreenChange: any): any

Generated using TypeDoc