Cocos Creator API

1.4.x

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

Sprite

Module: cc

Renders a sprite in the scene.

examples:

// Create a new node and add sprite components.
 var node = new cc.Node("New Sprite");
 var sprite = node.addComponent(cc.Sprite);
 node.parent = this.node;

Properties

spriteFrame SpriteFrame

The sprite frame of the sprite.

examples:

sprite.spriteFrame = newSpriteFrame;

type Sprite.SpriteType

The sprite render type.

examples:

sprite.type = cc.Sprite.Type.SIMPLE;

fillType Sprite.FillType

The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.

examples:

sprite.fillType = cc.Sprite.FillType.HORIZONTAL;

fillCenter Vec2

The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.

examples:

sprite.fillCenter = new cc.Vec2(0, 0);

fillStart Number

The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.

examples:

// -1 To 1 between the numbers
sprite.fillStart = 0.5;

fillRange Number

The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.

examples:

// -1 To 1 between the numbers
sprite.fillRange = 1;

trim Boolean

specify the frame is trimmed or not.

examples:

sprite.trim = true;

srcBlendFactor BlendFactor

specify the source Blend Factor.

examples:

sprite.srcBlendFactor = cc.BlendFunc.BlendFactor.ONE;

dstBlendFactor BlendFactor

specify the destination Blend Factor.

examples:

sprite.dstBlendFactor = cc.BlendFunc.BlendFactor.ONE;

sizeMode Sprite.SizeMode

specify the size tracing mode.

examples:

sprite.sizeMode = cc.Sprite.SizeMode.CUSTOM;

_sgNode _ccsg.Node private

Reference to the instance of _ccsg.Node If it is possible to return null from your overloaded _createSgNode, then you should always check for null before using this property and reimplement __preload.

__eventTargets Array private

Inherited from Component:

Register all related EventTargets, all event callbacks will be removed in _onPreDestroy

node Node

Inherited from Component:

The node this component is attached to. A component is always attached to a node.

examples:

cc.log(comp.node);

uuid String readOnly

Inherited from Component:

The uuid for editor.

examples:

cc.log(comp.uuid);

_enabled Boolean private

Inherited from Component:

enabled Boolean

Inherited from Component:

indicates whether this component is enabled or not.

examples:

comp.enabled = true;
cc.log(comp.enabled);

enabledInHierarchy Boolean readOnly

Inherited from Component:

indicates whether this component is enabled and its node is also active in the hierarchy.

examples:

cc.log(comp.enabledInHierarchy);

_isOnLoadCalled Boolean readOnly

Inherited from Component:

TODO

examples:

cc.log(_isOnLoadCalled);

_name String private

_objFlags Number private

name String

The name of the object.

examples:

obj.name = "New Obj";

isValid Boolean readOnly

Indicates whether the object is not yet destroyed.

examples:

cc.log(obj.isValid);

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

Methods

setInsetLeft
(
  • insetLeft
)

Change the left sprite's cap inset.

name type description