mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
+168
-109
@@ -22,49 +22,94 @@
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* Enum for sprite type
|
||||
* @enum SpriteType
|
||||
* !#en Enum for sprite type.
|
||||
* !#zh Sprite 类型
|
||||
* @enum Sprite.SpriteType
|
||||
*/
|
||||
/**
|
||||
/**
|
||||
* !#en The simple type.
|
||||
* !#zh 普通类型
|
||||
* @property {Number} SIMPLE
|
||||
*/
|
||||
/**
|
||||
* !#en The sliced type.
|
||||
* !#zh 切片(九宫格)类型
|
||||
* @property {Number} SLICED
|
||||
*/
|
||||
/**
|
||||
* !#en The tiled type.
|
||||
* !#zh 平铺类型
|
||||
* @property {Number} TILED
|
||||
*/
|
||||
/**
|
||||
* !#en The filled type.
|
||||
* !#zh 填充类型
|
||||
* @property {Number} FILLED
|
||||
*/
|
||||
var SpriteType = cc.Scale9Sprite.RenderingType;
|
||||
|
||||
/**
|
||||
* !#en Enum for fill type.
|
||||
* !#zh 填充类型
|
||||
* @enum Sprite.FillType
|
||||
*/
|
||||
/**
|
||||
* !#en The horizontal fill.
|
||||
* !#zh 水平方向填充
|
||||
* @property {Number} HORIZONTAL
|
||||
*/
|
||||
/**
|
||||
* !#en The vertical fill.
|
||||
* !#zh 垂直方向填充
|
||||
* @property {Number} VERTICAL
|
||||
*/
|
||||
/**
|
||||
* !#en The radial fill.
|
||||
* !#zh 径向填充
|
||||
* @property {Number} RADIAL
|
||||
*/
|
||||
var FillType = cc.Scale9Sprite.FillType;
|
||||
|
||||
var BlendFactor = cc.BlendFunc.BlendFactor;
|
||||
|
||||
/**
|
||||
* Sprite Size can track trimmed size, raw size or none
|
||||
* @enum SizeMode
|
||||
* !#en Sprite Size can track trimmed size, raw size or none.
|
||||
* !#zh 精灵尺寸调整模式
|
||||
* @enum Sprite.SizeMode
|
||||
*/
|
||||
var SizeMode = cc.Enum({
|
||||
/**
|
||||
* !#en Use the customized node size.
|
||||
* !#zh 使用节点预设的尺寸
|
||||
* @property {Number} CUSTOM
|
||||
*/
|
||||
CUSTOM: 0,
|
||||
/**
|
||||
* !#en Match the trimmed size of the sprite frame automatically.
|
||||
* !#zh 自动适配为精灵裁剪后的尺寸
|
||||
* @property {Number} TRIMMED
|
||||
*/
|
||||
TRIMMED: 1,
|
||||
/**
|
||||
* !#en Match the raw size of the sprite frame automatically.
|
||||
* !#zh 自动适配为精灵原图尺寸
|
||||
* @property {Number} RAW
|
||||
*/
|
||||
RAW: 2
|
||||
});
|
||||
|
||||
/**
|
||||
* Renders a sprite in the scene.
|
||||
* !#en Renders a sprite in the scene.
|
||||
* !#zh 该组件用于在场景中渲染精灵。
|
||||
* @class Sprite
|
||||
* @extends _RendererUnderSG
|
||||
* @example
|
||||
* // 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;
|
||||
*/
|
||||
var Sprite = cc.Class({
|
||||
name: 'cc.Sprite',
|
||||
@@ -96,11 +141,6 @@ var Sprite = cc.Class({
|
||||
_isTrimmedMode: true,
|
||||
_srcBlendFactor: BlendFactor.SRC_ALPHA,
|
||||
_dstBlendFactor: BlendFactor.ONE_MINUS_SRC_ALPHA,
|
||||
/**
|
||||
* The Sprite Atlas.
|
||||
* @property _atlas
|
||||
* @type {SpriteAtlas}
|
||||
*/
|
||||
_atlas: {
|
||||
default: null,
|
||||
type: cc.SpriteAtlas,
|
||||
@@ -111,9 +151,12 @@ var Sprite = cc.Class({
|
||||
},
|
||||
|
||||
/**
|
||||
* The sprite frame of the sprite.
|
||||
* !#en The sprite frame of the sprite.
|
||||
* !#zh 精灵的精灵帧
|
||||
* @property spriteFrame
|
||||
* @type {SpriteFrame}
|
||||
* @example
|
||||
* sprite.spriteFrame = newSpriteFrame;
|
||||
*/
|
||||
spriteFrame: {
|
||||
get: function () {
|
||||
@@ -131,9 +174,12 @@ var Sprite = cc.Class({
|
||||
},
|
||||
|
||||
/**
|
||||
* The sprite type.
|
||||
* !#en The sprite render type.
|
||||
* !#zh 精灵渲染类型
|
||||
* @property type
|
||||
* @type {SpriteType}
|
||||
* @type {Sprite.SpriteType}
|
||||
* @example
|
||||
* sprite.type = cc.Sprite.Type.SIMPLE;
|
||||
*/
|
||||
type: {
|
||||
get: function () {
|
||||
@@ -151,8 +197,14 @@ var Sprite = cc.Class({
|
||||
},
|
||||
|
||||
/**
|
||||
* Filled type
|
||||
* @property
|
||||
* !#en
|
||||
* The fill type, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
|
||||
* !#zh
|
||||
* 精灵填充类型,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。
|
||||
* @property fillType
|
||||
* @type {Sprite.FillType}
|
||||
* @example
|
||||
* sprite.fillType = cc.Sprite.FillType.HORIZONTAL;
|
||||
*/
|
||||
fillType : {
|
||||
get: function () {
|
||||
@@ -165,6 +217,16 @@ var Sprite = cc.Class({
|
||||
type: FillType
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* The fill Center, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
|
||||
* !#zh
|
||||
* 填充中心点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。
|
||||
* @property fillCenter
|
||||
* @type {Vec2}
|
||||
* @example
|
||||
* sprite.fillCenter = new cc.Vec2(0, 0);
|
||||
*/
|
||||
fillCenter: {
|
||||
get: function() {
|
||||
return this._fillCenter;
|
||||
@@ -175,6 +237,17 @@ var Sprite = cc.Class({
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* The fill Start, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
|
||||
* !#zh
|
||||
* 填充起始点,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。
|
||||
* @property fillStart
|
||||
* @type {Number}
|
||||
* @example
|
||||
* // -1 To 1 between the numbers
|
||||
* sprite.fillStart = 0.5;
|
||||
*/
|
||||
fillStart: {
|
||||
get: function() {
|
||||
return this._fillStart;
|
||||
@@ -185,6 +258,17 @@ var Sprite = cc.Class({
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* The fill Range, This will only have any effect if the "type" is set to “cc.Sprite.Type.FILLED”.
|
||||
* !#zh
|
||||
* 填充范围,仅渲染类型设置为 cc.Sprite.SpriteType.FILLED 时有效。
|
||||
* @property fillRange
|
||||
* @type {Number}
|
||||
* @example
|
||||
* // -1 To 1 between the numbers
|
||||
* sprite.fillRange = 1;
|
||||
*/
|
||||
fillRange: {
|
||||
get: function() {
|
||||
return this._fillRange;
|
||||
@@ -195,11 +279,14 @@ var Sprite = cc.Class({
|
||||
},
|
||||
},
|
||||
/**
|
||||
* specify the rendering mode
|
||||
* @property isTrimmedMode
|
||||
* !#en specify the frame is trimmed or not.
|
||||
* !#zh 是否使用裁剪模式
|
||||
* @property trim
|
||||
* @type {Boolean}
|
||||
* @example
|
||||
* sprite.trim = true;
|
||||
*/
|
||||
isTrimmedMode: {
|
||||
trim: {
|
||||
get: function () {
|
||||
return this._isTrimmedMode;
|
||||
},
|
||||
@@ -209,14 +296,16 @@ var Sprite = cc.Class({
|
||||
this._sgNode.enableTrimmedContentSize(value);
|
||||
}
|
||||
},
|
||||
animatable: false,
|
||||
displayName: "TrimmedMode"
|
||||
animatable: false
|
||||
},
|
||||
|
||||
/**
|
||||
* specify the source Blend Factor
|
||||
* !#en specify the source Blend Factor.
|
||||
* !#zh 指定原图的混合模式
|
||||
* @property srcBlendFactor
|
||||
* @type {BlendFactor}
|
||||
* @example
|
||||
* sprite.srcBlendFactor = cc.BlendFunc.BlendFactor.ONE;
|
||||
*/
|
||||
srcBlendFactor: {
|
||||
get: function() {
|
||||
@@ -232,9 +321,12 @@ var Sprite = cc.Class({
|
||||
},
|
||||
|
||||
/**
|
||||
* specify the destination Blend Factor
|
||||
* !#en specify the destination Blend Factor.
|
||||
* !#zh 指定目标的混合模式
|
||||
* @property dstBlendFactor
|
||||
* @type {BlendFactor}
|
||||
* @example
|
||||
* sprite.dstBlendFactor = cc.BlendFunc.BlendFactor.ONE;
|
||||
*/
|
||||
dstBlendFactor: {
|
||||
get: function() {
|
||||
@@ -264,9 +356,12 @@ var Sprite = cc.Class({
|
||||
tooltip: 'i18n:COMPONENT.sprite.original_size',
|
||||
},
|
||||
/**
|
||||
* specify the size tracing mode
|
||||
* !#en specify the size tracing mode.
|
||||
* !#zh 精灵尺寸调整模式
|
||||
* @property sizeMode
|
||||
* @type {SizeMode}
|
||||
* @type {Sprite.SizeMode}
|
||||
* @example
|
||||
* sprite.sizeMode = cc.Sprite.SizeMode.CUSTOM;
|
||||
*/
|
||||
sizeMode: {
|
||||
get: function () {
|
||||
@@ -290,162 +385,126 @@ var Sprite = cc.Class({
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets whether the sprite is visible or not.
|
||||
* !#en Sets whether the sprite is visible or not.
|
||||
* !#zh 设置精灵是否可见
|
||||
* @method setVisible
|
||||
* @param {Boolean} visible
|
||||
* @override
|
||||
* @example
|
||||
* sprite.setVisible(false);
|
||||
*/
|
||||
setVisible: function (visible) {
|
||||
this.enabled = visible;
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle 9-slice feature.
|
||||
* If Scale9Sprite is 9-slice disabled, the Scale9Sprite will rendered as a normal sprite.
|
||||
* @method setScale9Enabled
|
||||
* @param {Boolean} enabled - True to enable 9-slice, false otherwise.
|
||||
*/
|
||||
setScale9Enabled: function (enabled) {
|
||||
this.type = enabled ? cc.Scale9Sprite.RenderingType.SLICED : cc.Scale9Sprite.RenderingType.SIMPLE;
|
||||
},
|
||||
|
||||
/**
|
||||
* Query whether the Scale9Sprite is enable 9-slice or not.
|
||||
* @method isScale9Enabled
|
||||
* @return {Boolean} True if 9-slice is enabled, false otherwise.
|
||||
*/
|
||||
isScale9Enabled: function () {
|
||||
return this.type === cc.Scale9Sprite.RenderingType.SLICED;
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes a 9-slice sprite with a texture file, a delimitation zone and
|
||||
* with the specified cap insets.
|
||||
* Once the sprite is created, you can then call its "setContentSize:" method
|
||||
* to resize the sprite will all it's 9-slice goodness intract.
|
||||
* It respects the anchorPoint too.
|
||||
*
|
||||
* @method initWithFile
|
||||
* @param {String} file - The name of the texture file.
|
||||
* @param {Rect} rect - The rectangle that describes the sub-part of the texture that
|
||||
* is the whole image. If the shape is the whole texture, set this to the texture's full rect.
|
||||
* @param {Rect} capInsets - The values to use for the cap insets.
|
||||
*/
|
||||
initWithFile: function (file) {
|
||||
this._sgNode.initWithFile(file);
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes a 9-slice sprite with an sprite frame and with the specified
|
||||
* cap insets.
|
||||
* Once the sprite is created, you can then call its "setContentSize:" method
|
||||
* to resize the sprite will all it's 9-slice goodness intract.
|
||||
* It respects the anchorPoint too.
|
||||
*
|
||||
* @method initWithSpriteFrame
|
||||
* @param {SpriteFrame} spriteFrame - The sprite frame object.
|
||||
* @param {Rect} capInsets - The values to use for the cap insets.
|
||||
*/
|
||||
initWithSpriteFrame: function (spriteFrame) {
|
||||
this._spriteFrame = spriteFrame;
|
||||
this._sgNode.initWithSpriteFrame(spriteFrame);
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes a 9-slice sprite with an sprite frame name and with the specified
|
||||
* cap insets.
|
||||
* Once the sprite is created, you can then call its "setContentSize:" method
|
||||
* to resize the sprite will all it's 9-slice goodness intract.
|
||||
* It respects the anchorPoint too.
|
||||
*
|
||||
* @method initWithSpriteFrameName
|
||||
* @param {String} spriteFrameName - The sprite frame name.
|
||||
* @param {Rect} capInsets - The values to use for the cap insets.
|
||||
*/
|
||||
initWithSpriteFrameName: function (spriteFrameName) {
|
||||
var initialized = this._sgNode.initWithSpriteFrame(spriteFrameName);
|
||||
if (initialized === false) {
|
||||
return;
|
||||
}
|
||||
this._spriteFrame = this._sgNode.getSpriteFrame();
|
||||
},
|
||||
|
||||
/**
|
||||
* Query the sprite's original size.
|
||||
* !#en Query the sprite's original size.
|
||||
* !#zh 获取精灵原始大小
|
||||
* @method getOriginalSize
|
||||
* @return {Size} Sprite size.
|
||||
* @example
|
||||
* var originalSize = sprite.getOriginalSize();
|
||||
* cc.log("Original Size:" + originalSize);
|
||||
*/
|
||||
getOriginalSize: function () {
|
||||
return this._sgNode.getOriginalSize();
|
||||
},
|
||||
|
||||
/**
|
||||
* Change the left sprite's cap inset.
|
||||
* !#en Change the left sprite's cap inset.
|
||||
* !#zh 设置精灵左边框-用于九宫格。
|
||||
* @method setInsetLeft
|
||||
* @param {Number} leftInset - The values to use for the cap inset.
|
||||
* @param {Number} insetLeft - The values to use for the cap inset.
|
||||
* @example
|
||||
* sprite.setInsetLeft(5);
|
||||
*/
|
||||
setInsetLeft: function (insetLeft) {
|
||||
this._sgNode.setInsetLeft(insetLeft);
|
||||
},
|
||||
|
||||
/**
|
||||
* Query the left sprite's cap inset.
|
||||
* !#en Query the left sprite's cap inset.
|
||||
* !#zh 获取精灵左边框
|
||||
* @method getInsetLeft
|
||||
* @return {Number} The left sprite's cap inset.
|
||||
* @example
|
||||
* var insetLeft = sprite.getInsetLeft();
|
||||
* cc.log("Inset Left:" + insetLeft);
|
||||
*/
|
||||
getInsetLeft: function () {
|
||||
return this._sgNode.getInsetLeft();
|
||||
},
|
||||
|
||||
/**
|
||||
* Change the top sprite's cap inset.
|
||||
* !#en Change the top sprite's cap inset.
|
||||
* !#zh 设置精灵上边框-用于九宫格。
|
||||
* @method setInsetTop
|
||||
* @param {Number} topInset - The values to use for the cap inset.
|
||||
* @param {Number} insetTop - The values to use for the cap inset.
|
||||
* @example
|
||||
* sprite.setInsetTop(5);
|
||||
*/
|
||||
setInsetTop: function (insetTop) {
|
||||
this._sgNode.setInsetTop(insetTop);
|
||||
},
|
||||
|
||||
/**
|
||||
* Query the top sprite's cap inset.
|
||||
* !#en Query the top sprite's cap inset.
|
||||
* !#zh 获取精灵上边框。
|
||||
* @method getInsetTop
|
||||
* @return {Number} The top sprite's cap inset.
|
||||
* @example
|
||||
* var insetTop = sprite.getInsetTop();
|
||||
* cc.log("Inset Top:" + insetTop);
|
||||
*/
|
||||
getInsetTop: function () {
|
||||
return this._sgNode.getInsetTop();
|
||||
},
|
||||
|
||||
/**
|
||||
* Change the right sprite's cap inset.
|
||||
* !#en Change the right sprite's cap inset.
|
||||
* !#zh 设置精灵右边框-用于九宫格。
|
||||
* @method setInsetRight
|
||||
* @param {Number} rightInset - The values to use for the cap inset.
|
||||
* @param {Number} insetRight - The values to use for the cap inset.
|
||||
* @example
|
||||
* sprite.setInsetRight(5);
|
||||
*/
|
||||
setInsetRight: function (insetRight) {
|
||||
this._sgNode.setInsetRight(insetRight);
|
||||
},
|
||||
|
||||
/**
|
||||
* Query the right sprite's cap inset.
|
||||
* !#en Query the right sprite's cap inset.
|
||||
* !#zh 获取精灵右边框。
|
||||
* @method getInsetRight
|
||||
* @return {Number} The right sprite's cap inset.
|
||||
* @example
|
||||
* var insetRight = sprite.getInsetRight();
|
||||
* cc.log("Inset Right:" + insetRight);
|
||||
*/
|
||||
getInsetRight: function () {
|
||||
return this._sgNode.getInsetRight();
|
||||
},
|
||||
|
||||
/**
|
||||
* Change the bottom sprite's cap inset.
|
||||
* !#en Change the bottom sprite's cap inset.
|
||||
* !#zh 设置精灵下边框-用于九宫格。
|
||||
* @method setInsetBottom
|
||||
* @param {Number} bottomInset - The values to use for the cap inset.
|
||||
* @example
|
||||
* sprite.setInsetBottom(5);
|
||||
*/
|
||||
setInsetBottom: function (insetBottom) {
|
||||
this._sgNode.setInsetBottom(insetBottom);
|
||||
},
|
||||
|
||||
/**
|
||||
* @brief Query the bottom sprite's cap inset.
|
||||
* !#en Query the bottom sprite's cap inset.
|
||||
* !#zh 获取精灵下边框。
|
||||
* @method getInsetBottom
|
||||
* @return {Number} The bottom sprite's cap inset.
|
||||
* @example
|
||||
* var insetBottom = sprite.getInsetBottom();
|
||||
* cc.log("Inset Bottom:" + insetBottom);
|
||||
*/
|
||||
getInsetBottom: function () {
|
||||
return this._sgNode.getInsetBottom();
|
||||
|
||||
@@ -31,18 +31,6 @@ var game = require('../CCGame');
|
||||
require('../platform/_CCClass');
|
||||
require('../platform/CCClass');
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This class allows to easily create OpenGL or Canvas 2D textures from images, text or raw data. <br/>
|
||||
* The created cc.Texture2D object will always have power-of-two dimensions. <br/>
|
||||
* Depending on how you create the cc.Texture2D object, the actual image area of the texture might be smaller than the texture dimensions <br/>
|
||||
* i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0). <br/>
|
||||
* Be aware that the content of the generated textures will be upside-down! </p>
|
||||
|
||||
* @class Texture2D
|
||||
* @extends RawAsset
|
||||
*/
|
||||
|
||||
/**
|
||||
* The texture wrap mode
|
||||
* @class Texture2D.WrapMode
|
||||
@@ -72,6 +60,17 @@ var WrapMode = cc.Enum({
|
||||
MIRRORED_REPEAT: 0x8370
|
||||
});
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This class allows to easily create OpenGL or Canvas 2D textures from images, text or raw data. <br/>
|
||||
* The created cc.Texture2D object will always have power-of-two dimensions. <br/>
|
||||
* Depending on how you create the cc.Texture2D object, the actual image area of the texture might be smaller than the texture dimensions <br/>
|
||||
* i.e. "contentSize" != (pixelsWide, pixelsHigh) and (maxS, maxT) != (1.0, 1.0). <br/>
|
||||
* Be aware that the content of the generated textures will be upside-down! </p>
|
||||
|
||||
* @class Texture2D
|
||||
* @extends RawAsset
|
||||
*/
|
||||
var Texture2D = cc.Class(/** @lends cc.Texture2D# */{
|
||||
|
||||
name: 'cc.Texture2D',
|
||||
|
||||
@@ -60,17 +60,76 @@ cc.BlendFunc = function (src1, dst1) {
|
||||
this.dst = dst1;
|
||||
};
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Enum for blend factor
|
||||
* Refer to: http://www.andersriggelsen.dk/glblendfunc.php
|
||||
* !#zh
|
||||
* 混合因子
|
||||
* 可参考: http://www.andersriggelsen.dk/glblendfunc.php
|
||||
* @enum BlendFactor
|
||||
*/
|
||||
var BlendFactor = cc.Enum({
|
||||
ONE: 1, //cc.macro.ONE
|
||||
ZERO: 0, //cc.macro.ZERO
|
||||
SRC_ALPHA: 0x302, //cc.macro.SRC_ALPHA
|
||||
SRC_COLOR: 0x300, //cc.macro.SRC_COLOR
|
||||
DST_ALPHA: 0x304, //cc.macro.DST_ALPHA
|
||||
DST_COLOR: 0x306, //cc.macro.DST_COLOR
|
||||
ONE_MINUS_SRC_ALPHA: 0x303, //cc.macro.ONE_MINUS_SRC_ALPHA
|
||||
ONE_MINUS_SRC_COLOR: 0x301, //cc.macro.ONE_MINUS_SRC_COLOR
|
||||
ONE_MINUS_DST_ALPHA: 0x305, //cc.macro.ONE_MINUS_DST_ALPHA
|
||||
ONE_MINUS_DST_COLOR: 0x307, //cc.macro.ONE_MINUS_DST_COLOR
|
||||
/**
|
||||
* !#en All use
|
||||
* !#zh 全部使用
|
||||
* @property {Number} ONE
|
||||
*/
|
||||
ONE: 1, //cc.macro.ONE
|
||||
/**
|
||||
* !#en Not all
|
||||
* !#zh 全部不用
|
||||
* @property {Number} ZERO
|
||||
*/
|
||||
ZERO: 0, //cc.ZERO
|
||||
/**
|
||||
* !#en Using the source alpha
|
||||
* !#zh 使用源颜色的透明度
|
||||
* @property {Number} SRC_ALPHA
|
||||
*/
|
||||
SRC_ALPHA: 0x302, //cc.SRC_ALPHA
|
||||
/**
|
||||
* !#en Using the source color
|
||||
* !#zh 使用源颜色
|
||||
* @property {Number} SRC_COLOR
|
||||
*/
|
||||
SRC_COLOR: 0x300, //cc.SRC_COLOR
|
||||
/**
|
||||
* !#en Using the target alpha
|
||||
* !#zh 使用目标颜色的透明度
|
||||
* @property {Number} DST_ALPHA
|
||||
*/
|
||||
DST_ALPHA: 0x304, //cc.DST_ALPHA
|
||||
/**
|
||||
* !#en Using the target color
|
||||
* !#zh 使用目标颜色
|
||||
* @property {Number} DST_COLOR
|
||||
*/
|
||||
DST_COLOR: 0x306, //cc.DST_COLOR
|
||||
/**
|
||||
* !#en Minus the source alpha
|
||||
* !#zh 减去源颜色的透明度
|
||||
* @property {Number} ONE_MINUS_SRC_ALPHA
|
||||
*/
|
||||
ONE_MINUS_SRC_ALPHA: 0x303, //cc.ONE_MINUS_SRC_ALPHA
|
||||
/**
|
||||
* !#en Minus the source color
|
||||
* !#zh 减去源颜色
|
||||
* @property {Number} ONE_MINUS_SRC_COLOR
|
||||
*/
|
||||
ONE_MINUS_SRC_COLOR: 0x301, //cc.ONE_MINUS_SRC_COLOR
|
||||
/**
|
||||
* !#en Minus the target alpha
|
||||
* !#zh 减去目标颜色的透明度
|
||||
* @property {Number} ONE_MINUS_DST_ALPHA
|
||||
*/
|
||||
ONE_MINUS_DST_ALPHA: 0x305, //cc.ONE_MINUS_DST_ALPHA
|
||||
/**
|
||||
* !#en Minus the target color
|
||||
* !#zh 减去目标颜色
|
||||
* @property {Number} ONE_MINUS_DST_COLOR
|
||||
*/
|
||||
ONE_MINUS_DST_COLOR: 0x307, //cc.ONE_MINUS_DST_COLOR
|
||||
});
|
||||
|
||||
//var BlendFactor = cc;
|
||||
|
||||
@@ -23,12 +23,6 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* Renders a TMX Tile Map in the scene.
|
||||
* @class TiledMap
|
||||
* @extends Component
|
||||
*/
|
||||
|
||||
/**
|
||||
* The orientation of tiled map
|
||||
* @enum TiledMap.Orientation
|
||||
@@ -151,6 +145,11 @@ var TileFlag = cc.Enum({
|
||||
FLIPPED_MASK: (~((0x80000000 | 0x40000000 | 0x20000000) >>> 0)) >>> 0
|
||||
});
|
||||
|
||||
/**
|
||||
* Renders a TMX Tile Map in the scene.
|
||||
* @class TiledMap
|
||||
* @extends Component
|
||||
*/
|
||||
var TiledMap = cc.Class({
|
||||
name: 'cc.TiledMap',
|
||||
extends: cc._RendererInSG,
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
----------------------------------------------------
|
||||
// ----------------------------------------------------
|
||||
// 1. Create a cc.SpriteFrame with image path
|
||||
var frame1 = new cc.SpriteFrame("res/grossini_dance.png",cc.rect(0,0,90,128));
|
||||
var frame2 = new cc.SpriteFrame("res/grossini_dance.png",cc.rect(0,0,90,128),false,0,cc.size(90,128));
|
||||
|
||||
var url = cc.url.raw('resources/textures/grossini_dance.png');
|
||||
var frame1 = new cc.SpriteFrame(url, cc.Rect(0, 0, 90, 128));
|
||||
|
||||
// ----------------------------------------------------
|
||||
// 2. Create a cc.SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
|
||||
var texture = cc.textureCache.addImage("res/grossini_dance.png");
|
||||
var frame1 = new cc.SpriteFrame(texture, cc.rect(0,0,90,128));
|
||||
var frame2 = new cc.SpriteFrame(texture, cc.rect(0,0,90,128),false,0,cc.size(90,128));
|
||||
var url = cc.url.raw('resources/textures/grossini_dance.png');
|
||||
var texture = cc.textureCache.addImage(url);
|
||||
var frame1 = new cc.SpriteFrame(texture, cc.Rect(0, 0, 90, 128));
|
||||
var frame2 = new cc.SpriteFrame(texture, cc.Rect(0, 0, 90, 128), false, 0, cc.Size(90, 128));
|
||||
|
||||
// ----------------------------------------------------
|
||||
// 3. load a cc.SpriteFrame with image path (Recommend)
|
||||
var url = 'resources://test assets/PurpleMonster.png/PurpleMonster';
|
||||
var self = this;
|
||||
cc.loader.load(url, function (err, spriteFrame) {
|
||||
var node = new cc.Node("New Sprite");
|
||||
var sprite = node.addComponent(cc.Sprite);
|
||||
sprite.spriteFrame = spriteFrame;
|
||||
node.parent = self.node
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user