Merge branch 'v1.0' of github.com:cocos-creator/engine

This commit is contained in:
Nan Wang
2016-03-28 11:12:38 +08:00
23 changed files with 596 additions and 251 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ _p = null;
* @name cc.ENGINE_VERSION
*/
var engineVersion;
engineVersion = '0.8.0-beta.9';
engineVersion = '1.0.0-rc.1';
window['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
/**
+1 -1
View File
@@ -1038,7 +1038,7 @@ var Node = cc.Class({
* node.on(cc.Node.EventType.TOUCH_START, callback, this.node);
* node.on(cc.Node.EventType.TOUCH_MOVE, callback, this.node);
* node.on(cc.Node.EventType.TOUCH_END, callback, this.node);
* node.on(cc.Node.EventType.TOUCH_END, callback, this.node);
* node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this.node);
*/
on: function (type, callback, target) {
if (_touchEvents.indexOf(type) !== -1) {
-6
View File
@@ -182,12 +182,6 @@ var AudioSource = cc.Class({
}
},
onLoad: function () {
if ( this.isPlaying ) {
this.stop();
}
},
onEnable: function () {
if ( this.playOnLoad ) {
this.play();
+28
View File
@@ -455,6 +455,34 @@ var EditBox = cc.Class({
editBoxTextChanged: function(editBox, text) {
cc.Component.EventHandler.emitEvents(this.textChanged, text);
},
onLoad: function() {
this._super();
if (!CC_EDITOR) {
this._registerEvent();
}
},
_registerEvent: function () {
this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this);
this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
},
_onTouchBegan: function(event) {
if (this._sgNode) {
this._sgNode._onTouchBegan(event.touch);
}
event.stopPropagation();
},
_onTouchEnded: function(event) {
if (this._sgNode) {
this._sgNode._onTouchEnded();
}
event.stopPropagation();
}
});
cc.EditBox = module.exports = EditBox;
+13 -5
View File
@@ -211,7 +211,8 @@ var Sprite = cc.Class({
this._fillType = value;
this._sgNode && this._sgNode.setFillType(value);
},
type: FillType
type: FillType,
tooltip: 'i18n:COMPONENT.sprite.fill_type'
},
/**
@@ -232,6 +233,7 @@ var Sprite = cc.Class({
this._fillCenter = cc.v2(value);
this._sgNode && this._sgNode.setFillCenter(this._fillCenter);
},
tooltip: 'i18n:COMPONENT.sprite.fill_center',
},
/**
@@ -253,6 +255,7 @@ var Sprite = cc.Class({
this._fillStart = cc.clampf(value, -1, 1);
this._sgNode && this._sgNode.setFillStart(value);
},
tooltip: 'i18n:COMPONENT.sprite.fill_start'
},
/**
@@ -274,6 +277,7 @@ var Sprite = cc.Class({
this._fillRange = cc.clampf(value, -1, 1);
this._sgNode && this._sgNode.setFillRange(value);
},
tooltip: 'i18n:COMPONENT.sprite.fill_range'
},
/**
* !#en specify the frame is trimmed or not.
@@ -293,7 +297,8 @@ var Sprite = cc.Class({
this._sgNode.enableTrimmedContentSize(value);
}
},
animatable: false
animatable: false,
tooltip: 'i18n:COMPONENT.sprite.trim'
},
/**
@@ -314,7 +319,8 @@ var Sprite = cc.Class({
this._sgNode.setBlendFunc(this._blendFunc);
},
animatable: false,
type:BlendFactor
type:BlendFactor,
tooltip: 'i18n:COMPONENT.sprite.src_blend_factor'
},
/**
@@ -335,7 +341,8 @@ var Sprite = cc.Class({
this._sgNode.setBlendFunc(this._blendFunc);
},
animatable: false,
type: BlendFactor
type: BlendFactor,
tooltip: 'i18n:COMPONENT.sprite.dst_blend_factor'
},
//FIXME:_useOriginalSize is deprecated, since v0.8, it need to be deleted
@@ -371,7 +378,8 @@ var Sprite = cc.Class({
}
},
animatable: false,
type: SizeMode
type: SizeMode,
tooltip: 'i18n:COMPONENT.sprite.size_mode'
}
},
-11
View File
@@ -698,23 +698,12 @@ _ccsg.EditBox = _ccsg.Node.extend({
this.setContentSize = this._updateEditBoxSize;
this.initWithSizeAndBackgroundSprite(size, normal9SpriteBg);
this._registerTouchEvent();
this.scheduleOnce(function () {
editBoxImpl.registerClickEvent();
}, 0.01);
},
_registerTouchEvent: function() {
var touchListener = cc.EventListener.create({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches: true,
onTouchBegan: this._onTouchBegan.bind(this),
onTouchEnded: this._onTouchEnded.bind(this),
});
cc.eventManager.addListener(touchListener, this);
},
_onTouchBegan: function (touch, event) {
var touchPoint = touch.getLocation();
var bb = cc.rect(0,0, this._contentSize.width, this._contentSize.height);
+32 -19
View File
@@ -33,12 +33,18 @@
*
* !#zh
* 封装用户的事件处理逻辑。
* 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 cc.EventListener.create。
* 注意:这是一个抽象类,开发者不应该直接实例化这个类,请参考 {{#crossLink "EventListener/create:method"}}cc.EventListener.create{{/crossLink}}。
*
* @class EventListener
*/
/**
* Constructor
* @method EventListener
* @param {Number} type
* @param {Number} listenerID
* @param {Number} callback
* @return {EventListner}
*/
cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
_onEvent: null, // Event callback function
@@ -247,59 +253,66 @@ cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
// event listener type
/**
* !#en The type code of unknown event listener.
* !#zh 未知的事件监听器类型。
* @property EventListener.UNKNOWN
* @constant
* !#zh 未知的事件监听器类型
* @property UNKNOWN
* @type {Number}
* @static
*/
cc.EventListener.UNKNOWN = 0;
/*
* !#en The type code of one by one touch event listener.
* !#zh 触摸事件监听器类型,触点会一个一个得分开被派发。
* @constant
* !#zh 触摸事件监听器类型,触点会一个一个得分开被派发
* @property TOUCH_ONE_BY_ONE
* @type {Number}
* @static
*/
cc.EventListener.TOUCH_ONE_BY_ONE = 1;
/*
* !#en The type code of all at once touch event listener.
* !#zh 触摸事件监听器类型,触点会被一次性全部派发。
* @constant
* !#zh 触摸事件监听器类型,触点会被一次性全部派发
* @property TOUCH_ALL_AT_ONCE
* @type {Number}
* @static
*/
cc.EventListener.TOUCH_ALL_AT_ONCE = 2;
/**
* !#en The type code of keyboard event listener.
* !#zh 键盘事件监听器类型。
* @constant EventListener.KEYBOARD
* !#zh 键盘事件监听器类型
* @property KEYBOARD
* @type {Number}
* @static
*/
cc.EventListener.KEYBOARD = 3;
/*
* !#en The type code of mouse event listener.
* !#zh 鼠标事件监听器类型。
* @constant
* !#zh 鼠标事件监听器类型
* @property MOUSE
* @type {Number}
* @static
*/
cc.EventListener.MOUSE = 4;
/**
* !#en The type code of focus event listener.
* !#zh 加速器事件监听器类型。
* @constant EventListener.ACCELERATION
* !#zh 加速器事件监听器类型
* @property ACCELERATION
* @type {Number}
* @static
*/
cc.EventListener.ACCELERATION = 6;
/*
* !#en The type code of Focus change event listener.
* !#zh 焦点事件监听器类型。
* @constant
* !#zh 焦点事件监听器类型
* @property FOCUS
* @type {Number}
* @static
*/
cc.EventListener.FOCUS = 7;
/*
* !#en The type code of custom event listener.
* !#zh 自定义事件监听器类型。
* @constant
* !#zh 自定义事件监听器类型
* @property CUSTOM
* @type {Number}
* @static
*/
cc.EventListener.CUSTOM = 8;
@@ -456,9 +469,9 @@ cc._EventListenerTouchAllAtOnce.LISTENER_ID = "__cc_touch_all_at_once";
* all custom parameters will be polyfilled into the event listener object and can be accessed in handlers.
* !#zh 通过指定不同的 Event 对象来设置想要创建的事件监听器。
* @method create
* @static
* @param {Object} argObj a json object
* @returns {EventListener}
* @static
* @example {@link utils/api/engine/docs/cocos2d/core/event-manager/CCEventListener/create.js}
*/
cc.EventListener.create = function(argObj){
+1 -1
View File
@@ -173,7 +173,7 @@ JS.mixin(EventMouse.prototype, {
/**
* !#en Returns the X axis delta distance from the previous location to current location.
* !#zh 获取鼠标距离上一次事件移动的 X 轴距离。
* @method getDeltaX。
* @method getDeltaX
* @return {Number}
*/
getDeltaX: function () {
+5 -7
View File
@@ -261,23 +261,22 @@ JS.mixin(cc.loader, {
* @method loadRes
* @param {String} url - Url of the target resource.
* The url is relative to the "resources" folder, extensions must be omitted.
* @param {Function} [progressCallback] - Callback invoked when progression change. See {{#crossLink "Pipeline/onProgress:method"}}Pipeline.onProgress{{/crossLink}}.
* @param {Function} completeCallback - Callback invoked when the resource loaded.
* @param {Error} completeCallback.error - The error info or null if loaded successfully.
* @param {Object} completeCallback.resource - The loaded resource if it can be found otherwise returns null.
*
* @example
*
* // load the texture (project/assets/resources/imgs/cocos.png) from resources folder with no extension
* cc.loader.load('imgs/cocos', function (err, texture) {
* // load the sprite frame (project/assets/resources/imgs/cocos.png/cocos) from resources folder with no extension
* cc.loader.loadRes('imgs/cocos/cocos', function (err, spriteFrame) {
* if (err) {
* cc.error(err.message || err);
* return;
* }
* cc.log('Result should be a texture: ' + (texture instanceof cc.Texture2D));
* cc.log('Result should be a sprite frame: ' + ( spriteFrame instanceof cc.SpriteFrame));
* });
*/
loadRes: function (url, progressCallback, completeCallback) {
loadRes: function (url, completeCallback) {
var uuid = this._getResUuid(url);
if (uuid) {
this.load(
@@ -286,7 +285,6 @@ JS.mixin(cc.loader, {
type: 'uuid',
uuid: uuid
},
progressCallback,
completeCallback
);
}
@@ -368,4 +366,4 @@ JS.mixin(cc.loader, {
}
});
module.exports = cc.loader;
module.exports = cc.loader;
+9 -9
View File
@@ -902,7 +902,7 @@ cc.ContainerStrategy = cc._Class.extend(/** @lends cc.ContainerStrategy# */{
/**
* Manipulation before appling the strategy
* @method preApply
* @param {view} view - The target view
* @param {View} view - The target view
*/
preApply: function (view) {
},
@@ -910,7 +910,7 @@ cc.ContainerStrategy = cc._Class.extend(/** @lends cc.ContainerStrategy# */{
/**
* Function to apply this strategy
* @method apply
* @param {view} view
* @param {View} view
* @param {Size} designedResolution
*/
apply: function (view, designedResolution) {
@@ -919,7 +919,7 @@ cc.ContainerStrategy = cc._Class.extend(/** @lends cc.ContainerStrategy# */{
/**
* Manipulation after applying the strategy
* @method postApply
* @param {view} view The target view
* @param {View} view The target view
*/
postApply: function (view) {
@@ -1015,7 +1015,7 @@ cc.ContentStrategy = cc._Class.extend(/** @lends cc.ContentStrategy# */{
/**
* Manipulation before applying the strategy
* @method preApply
* @param {view} view - The target view
* @param {View} view - The target view
*/
preApply: function (view) {
},
@@ -1025,7 +1025,7 @@ cc.ContentStrategy = cc._Class.extend(/** @lends cc.ContentStrategy# */{
* The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
* The target view can then apply these value to itself, it's preferred not to modify directly its private variables
* @method apply
* @param {view} view
* @param {View} view
* @param {Size} designedResolution
* @return {Object} scaleAndViewportRect
*/
@@ -1036,7 +1036,7 @@ cc.ContentStrategy = cc._Class.extend(/** @lends cc.ContentStrategy# */{
/**
* Manipulation after applying the strategy
* @method postApply
* @param {view} view - The target view
* @param {View} view - The target view
*/
postApply: function (view) {
}
@@ -1243,7 +1243,7 @@ cc.ResolutionPolicy = cc._Class.extend(/** @lends cc.ResolutionPolicy# */{
/**
* Manipulation before applying the resolution policy
* @method preApply
* @param {view} view The target view
* @param {View} view The target view
*/
preApply: function (view) {
this._containerStrategy.preApply(view);
@@ -1255,7 +1255,7 @@ cc.ResolutionPolicy = cc._Class.extend(/** @lends cc.ResolutionPolicy# */{
* The return value is {scale: [scaleX, scaleY], viewport: {cc.Rect}},
* The target view can then apply these value to itself, it's preferred not to modify directly its private variables
* @method apply
* @param {view} view - The target view
* @param {View} view - The target view
* @param {Size} designedResolution - The user defined design resolution
* @return {Object} An object contains the scale X/Y values and the viewport rect
*/
@@ -1267,7 +1267,7 @@ cc.ResolutionPolicy = cc._Class.extend(/** @lends cc.ResolutionPolicy# */{
/**
* Manipulation after appyling the strategy
* @method postApply
* @param {view} view - The target view
* @param {View} view - The target view
*/
postApply: function (view) {
this._containerStrategy.postApply(view);
+3 -2
View File
@@ -45,8 +45,9 @@ function _copyprop(name, source, target) {
/**
* This module provides some JavaScript utilities.
*
* @module cc.js
* All members can be accessed with cc.js
* @module js
* @namespace cc.js
*/
var js = {
+24 -15
View File
@@ -73,9 +73,6 @@ cc.SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
var texture = cc.textureCache.addImage(url);
this._refreshTexture(texture);
if (this._textureLoaded) {
this._checkRect(texture);
}
}
}
}
@@ -241,12 +238,12 @@ cc.SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
* @param {Texture2D} texture
*/
_refreshTexture: function (texture) {
if (this._texture !== texture) {
var self = this;
if (self._texture !== texture) {
var locLoaded = texture.isLoaded();
this._textureLoaded = locLoaded;
this._texture = texture;
var self = this;
var textureLoadedCallback = function () {
function textureLoadedCallback () {
self._textureLoaded = true;
if (self._rotated && cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
var tempElement = texture.getHtmlElementObj();
@@ -260,25 +257,41 @@ cc.SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
self.setRect(cc.rect(0, 0, rect.width, rect.height));
}
var w = texture.width, h = texture.height;
if (!self._rect) {
if (self._rect) {
self._checkRect(texture);
}
else {
self.setRect(cc.rect(0, 0, w, h));
}
if (!self._originalSize) {
self.setOriginalSize(cc.size(w, h));
}
if (!self._offset) {
self.setOffset(cc.v2(0, 0));
}
//dispatch 'load' event of cc.SpriteFrame
self.emit("load");
};
}
if (!locLoaded) {
texture.once("load", textureLoadedCallback, this);
} else {
if (locLoaded) {
textureLoadedCallback();
}
else {
texture.once("load", textureLoadedCallback);
}
}
//if (texture && texture.url && texture.isLoaded()) {
// if (self._rect) {
// self._checkRect(texture);
// }
// else {
// self.setRect(cc.rect(0, 0, texture.width, texture.height));
// }
//}
},
/**
@@ -357,10 +370,6 @@ cc.SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
//todo log error
}
if (texture && texture.url && texture.isLoaded()) {
this._checkRect(texture);
}
return true;
},
+1 -2
View File
@@ -33,8 +33,7 @@ require('../platform/CCClass');
/**
* The texture wrap mode
* @class Texture2D.WrapMode
* @static
* @enum Texture2D.WrapMode
*/
var WrapMode = cc.Enum({
/**
+6 -3
View File
@@ -27,12 +27,15 @@ var ValueType = require('./CCValueType');
var JS = require('../platform/js');
/**
* cc.Size is the class for size object, please do not use its constructor to create sizes, use cc.size() alias function instead.
* cc.Size is the class for size object, please do not use its constructor to create sizes, use {{#crossLink "cc/size:method"}}{{/crossLink}} alias function instead.
* It will be deprecated soon, please use cc.Vec2 instead
* @class cc.Size
* @class Size
*/
/**
* @method Size
* @param {Number} width
* @param {Number} height
* @see cc.size
* @return {Size}
*/
function Size (width, height) {
if (width && typeof width === 'object') {
+2 -1
View File
@@ -153,7 +153,8 @@ cc.gl.blendFuncForParticle = function(sfactor, dfactor) {
ctx.disable(ctx.BLEND);
} else {
ctx.enable(ctx.BLEND);
//TODO need fix for WebGL
// TODO need fix for WebGL
// DO NOT TOUCH THIS, YOU MAY NOT BE ABLE TO FIX EVERYTHING
ctx.blendFuncSeparate(ctx.SRC_ALPHA, dfactor, sfactor, dfactor);
}
}
+56 -18
View File
@@ -25,8 +25,9 @@
****************************************************************************/
/**
* cc.TMXObjectGroup represents the TMX object group.
* @class
* !#en cc.TMXObjectGroup represents the TMX object group.
* !#zh TMXObjectGroup 用来表示 TMX 对象组。
* @class TMXObjectGroup
* @extends cc._Class
*
* @property {Array} properties - Properties from the group. They can be added using tilemap editors
@@ -52,16 +53,24 @@ cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
},
/**
* Offset position of child objects
* @return {cc.Vec2}
* !#en Offset position of child objects.
* !#zh 获取子对象的偏移位置。
* @method getPositionOffset
* @return {Vec2}
* @example
* var offset = tMXObjectGroup.getPositionOffset();
*/
getPositionOffset:function () {
return cc.p(this._positionOffset);
},
/**
* Offset position of child objects
* @param {cc.Vec2} offset
* !#en Offset position of child objects.
* !#zh 设置子对象的偏移位置。
* @method setPositionOffset
* @param {Vec2} offset
* @example
* tMXObjectGroup.setPositionOffset(cc.v2(5, 5));
*/
setPositionOffset:function (offset) {
this._positionOffset.x = offset.x;
@@ -69,32 +78,48 @@ cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
},
/**
* List of properties stored in a dictionary
* !#en List of properties stored in a dictionary.
* !#zh 以映射的形式获取属性列表。
* @method getProperties
* @return {Array}
* @example
* var offset = tMXObjectGroup.getProperties();
*/
getProperties:function () {
return this.properties;
},
/**
* List of properties stored in a dictionary
* @param {object} Var
* !#en List of properties stored in a dictionary.
* !#zh 设置属性列表。
* @method setProperties
* @param {Object} Var
* @example
* tMXObjectGroup.setProperties(obj);
*/
setProperties:function (Var) {
this.properties.push(Var);
},
/**
* Gets the Group name.
* !#en Gets the Group name.
* !#zh 获取组名称。
* @method getGroupName
* @return {String}
* @example
* var groupName = tMXObjectGroup.getGroupName;
*/
getGroupName:function () {
return this.groupName.toString();
},
/**
* Set the Group name
* !#en Set the Group name.
* !#zh 设置组名称。
* @method setGroupName
* @param {String} groupName
* @example
* tMXObjectGroup.setGroupName("New Group");
*/
setGroupName:function (groupName) {
this.groupName = groupName;
@@ -103,7 +128,7 @@ cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
/**
* Return the value for the specific property name
* @param {String} propertyName
* @return {object}
* @return {Object}
*/
propertyNamed:function (propertyName) {
return this.properties[propertyName];
@@ -121,10 +146,15 @@ cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
},
/**
* <p>Return the dictionary for the specific object name. <br />
* It will return the 1st object found on the array for the given name.</p>
* !#en
* Return the object for the specific object name. <br />
* It will return the 1st object found on the array for the given name.
* !#zh 获取指定的对象。
* @method getObject
* @param {String} objectName
* @return {object|Null}
* @return {Object|Null}
* @example
* var object = tMXObjectGroup.getObject("Group");
*/
getObject: function(objectName){
if (this._objects && this._objects.length > 0) {
@@ -140,16 +170,24 @@ cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
},
/**
* Gets the objects.
* !#en Gets the objects.
* !#zh 获取对象数组。
* @method getObjects
* @return {Array}
* @example
* var objects = tMXObjectGroup.getObjects();
*/
getObjects:function () {
return this._objects;
},
/**
* Set the objects.
* @param {object} objects
* !#en Set the objects.
* !#zh 设置对象数组。
* @method setObjects
* @param {Object} objects
* @example
* tMXObjectGroup.setObjects(objects);
*/
setObjects:function (objects) {
this._objects.push(objects);
+141 -38
View File
@@ -24,7 +24,8 @@
****************************************************************************/
/**
* Render the TMX layer.
* !#en Render the TMX layer.
* !#zh 渲染 TMX layer。
* @class TiledLayer
* @extends _SGComponent
*/
@@ -90,9 +91,13 @@ var TiledLayer = cc.Class({
},
/**
* Gets the layer name
* !#en Gets the layer name.
* !#zh 获取层的名称。
* @method getLayerName
* @return {String}
* @example
* var layerName = tiledLayer.getLayerName();
* cc.log(layerName);
*/
getLayerName: function() {
if (this._sgNode) {
@@ -102,9 +107,12 @@ var TiledLayer = cc.Class({
},
/**
* Set the layer name
* !#en Set the layer name.
* !#zh 设置层的名称
* @method SetLayerName
* @param {String} layerName
* @example
* tiledLayer.setLayerName("New Layer");
*/
setLayerName:function (layerName) {
if (this._sgNode) {
@@ -113,10 +121,14 @@ var TiledLayer = cc.Class({
},
/**
* Return the value for the specific property name
* !#en Return the value for the specific property name.
* !#zh 获取指定属性名的值。
* @method getProperty
* @param {String} propertyName
* @return {*}
* @example
* var property = tiledLayer.getProperty("info");
* cc.log(property);
*/
getProperty:function (propertyName) {
if (this._sgNode) {
@@ -127,11 +139,17 @@ var TiledLayer = cc.Class({
},
/**
* Returns the position in pixels of a given tile coordinate
* !#en Returns the position in pixels of a given tile coordinate.
* !#zh 获取指定 ttile 的像素坐标。
* @method getPositionAt
* @param {Vec2|Number} pos position or x
* @param {Number} [y]
* @return {Vec2}
* @example
* var pos = tiledLayer.getPositionAt(cc.v2(0, 0));
* cc.log("Pos: " + pos);
* var pos = tiledLayer.getPositionAt(0, 0);
* cc.log("Pos: " + pos);
*/
getPositionAt:function (pos, y) {
if (this._sgNode) {
@@ -144,10 +162,14 @@ var TiledLayer = cc.Class({
},
/**
* Removes a tile at given tile coordinate
* !#en Removes a tile at given tile coordinate.
* !#zh 删除指定坐标上的 tile。
* @method removeTileAt
* @param {Vec2|Number} pos position or x
* @param {Number} [y]
* @example
* tiledLayer.removeTileAt(cc.v2(0, 0));
* tiledLayer.removeTileAt(0, 0);
*/
removeTileAt:function (pos, y) {
if (this._sgNode) {
@@ -158,14 +180,21 @@ var TiledLayer = cc.Class({
},
/**
* <p>Sets the tile gid (gid = tile global id) at a given tile coordinate.<br />
* !#en
* Sets the tile gid (gid = tile global id) at a given tile coordinate.<br />
* The Tile GID can be obtained by using the method "tileGIDAt" or by using the TMX editor . Tileset Mgr +1.<br />
* If a tile is already placed at that position, then it will be removed.</p>
* If a tile is already placed at that position, then it will be removed.
* !#zh
* 设置给定坐标的 tile 的 gid (gid = tile 全局 id),
* tile 的 GID 可以使用方法 “tileGIDAt” 来获得。<br />
* 如果一个 tile 已经放在那个位置,那么它将被删除。
* @method setTileGID
* @param {Number} gid
* @param {Vec2|Number} posOrX position or x
* @param {Number} flagsOrY flags or y
* @param {Number} [flags]
* @example
* tiledLayer.setTileGID(1001, 10, 10, 1)
*/
setTileGID: function(gid, posOrX, flagsOrY, flags) {
if (this._sgNode) {
@@ -199,13 +228,20 @@ var TiledLayer = cc.Class({
//},
/**
* !#en
* Returns the tile gid at a given tile coordinate. <br />
* if it returns 0, it means that the tile is empty. <br />
* This method requires the the tile map has not been previously released (eg. don't call layer.releaseMap())<br />
* !#zh
* 通过给定的 tile 坐标、flags(可选)返回 tile 的 GID. <br />
* 如果它返回 0,则表示该 tile 为空。<br />
* 该方法要求 tile 地图之前没有被释放过(如:没有调用过layer.releaseMap()).
* @method getTileGIDAt
* @param {Vec2|Number} pos or x
* @param {Number} [y]
* @return {Number}
* @example
* var tileGid = tiledLayer.getTileGIDAt(0, 0);
*/
getTileGIDAt:function (pos, y) {
if (this._sgNode) {
@@ -217,16 +253,26 @@ var TiledLayer = cc.Class({
},
/**
* <p>Returns the tile (_ccsg.Sprite) at a given a tile coordinate. <br/>
* !#en
* Returns the tile (_ccsg.Sprite) at a given a tile coordinate. <br/>
* The returned _ccsg.Sprite will be already added to the _ccsg.TMXLayer. Don't add it again.<br/>
* The _ccsg.Sprite can be treated like any other _ccsg.Sprite: rotated, scaled, translated, opacity, color, etc. <br/>
* You can remove either by calling: <br/>
* - layer.removeChild(sprite, cleanup); <br/>
* - or layer.removeTileAt(ccp(x,y)); </p>
* - or layer.removeTileAt(ccp(x,y));
* !#zh
* 通过指定的 tile 坐标获取对应的 tile(Sprite)。 返回的 tile(Sprite) 应是已经添加到 TMXLayer,请不要重复添加。<br/>
* 这个 tile(Sprite) 如同其他的 Sprite 一样,可以旋转、缩放、翻转、透明化、设置颜色等。<br/>
* 你可以通过调用以下方法来对它进行删除:<br/>
* 1. layer.removeChild(sprite, cleanup);<br/>
* 2. 或 layer.removeTileAt(cc.v2(x,y));
* @method getTileAt
* @param {cc.Vec2|Number} pos or x
* @param {Vec2|Number} pos or x
* @param {Number} [y]
* @return {_ccsg.Sprite}
* @example
* var title = tiledLayer.getTileAt(100, 100);
* cc.log(title);
*/
getTileAt: function (pos, y) {
if (this._sgNode) {
@@ -238,10 +284,17 @@ var TiledLayer = cc.Class({
},
/**
* <p>Dealloc the map that contains the tile position from memory. <br />
* !#en
* Dealloc the map that contains the tile position from memory. <br />
* Unless you want to know at runtime the tiles positions, you can safely call this method. <br />
* If you are going to call layer.getTileGIDAt() then, don't release the map</p>
* If you are going to call layer.getTileGIDAt() then, don't release the map.
* !#zh
* 从内存中释放包含 tile 位置信息的地图。<br />
* 除了在运行时想要知道 tiles 的位置信息外,你都可安全的调用此方法。<br />
* 如果你之后还要调用 layer.tileGIDAt(), 请不要释放地图.
* @method releaseMap
* @example
* tiledLayer.releaseMap();
*/
releaseMap:function () {
if (this._sgNode) {
@@ -250,10 +303,13 @@ var TiledLayer = cc.Class({
},
/**
* Sets the untransformed size of the _ccsg.TMXLayer.
* !#en Sets the untransformed size of the _ccsg.TMXLayer.
* !#zh 设置未转换的 layer 大小。
* @method setContentSize
* @param {cc.Size|Number} size The untransformed size of the _ccsg.TMXLayer or The untransformed size's width of the TMXLayer.
* @param {Size|Number} size The untransformed size of the _ccsg.TMXLayer or The untransformed size's width of the TMXLayer.
* @param {Number} [height] The untransformed size's height of the _ccsg.TMXLayer.
* @example
* tiledLayer.setContentSize(100, 100);
*/
setContentSize:function (size, height) {
if (this._sgNode) {
@@ -264,9 +320,13 @@ var TiledLayer = cc.Class({
},
/**
* Return texture of cc.SpriteBatchNode
* !#en Return texture of cc.SpriteBatchNode.
* !#zh 获取纹理。
* @method getTexture
* @return {cc.Texture2D}
* @return {Texture2D}
* @example
* var texture = tiledLayer.getTexture();
* cc.log("Texture: " + texture);
*/
getTexture: function(){
if (this._sgNode) {
@@ -276,9 +336,12 @@ var TiledLayer = cc.Class({
},
/**
* Set the texture of cc.SpriteBatchNode
* !#en Set the texture of cc.SpriteBatchNode.
* !#zh 设置纹理。
* @method setTexture
* @param {cc.Texture2D} texture
* @param {Texture2D} texture
* @example
* tiledLayer.setTexture(texture);
*/
setTexture: function(texture){
if (this._sgNode) {
@@ -287,9 +350,13 @@ var TiledLayer = cc.Class({
},
/**
* Gets layer size.
* !#en Gets layer size.
* !#zh 获得层大小。
* @method getLayerSize
* @return {cc.Size}
* @return {Size}
* @example
* var size = tiledLayer.getLayerSize();
* cc.log("layer size: " + size);
*/
getLayerSize:function () {
if (this._sgNode) {
@@ -299,9 +366,12 @@ var TiledLayer = cc.Class({
},
/**
* Set layer size
* !#en Set layer size.
* !#zh 设置层大小。
* @method setLayerSize
* @param {cc.Size} layerSize
* @param {Size} layerSize
* @example
* tiledLayer.setLayerSize(new cc.size(5, 5));
*/
setLayerSize:function (layerSize) {
if (this._sgNode) {
@@ -310,9 +380,13 @@ var TiledLayer = cc.Class({
},
/**
* Size of the map's tile (could be different from the tile's size)
* !#en Size of the map's tile (could be different from the tile's size).
* !#zh 获取 tile 的大小( tile 的大小可能会有所不同)。
* @method getMapTileSize
* @return {cc.Size}
* @return {Size}
* @example
* var mapTileSize = tiledLayer.getMapTileSize();
* cc.log("MapTile size: " + mapTileSize);
*/
getMapTileSize:function () {
if (this._sgNode) {
@@ -322,9 +396,12 @@ var TiledLayer = cc.Class({
},
/**
* Set the map tile size.
* !#en Set the map tile size.
* !#zh 设置 tile 的大小。
* @method setMapTileSize
* @param {cc.Size} tileSize
* @param {Size} tileSize
* @example
* tiledLayer.setMapTileSize(new cc.size(10, 10));
*/
setMapTileSize:function (tileSize) {
if (this._sgNode) {
@@ -333,9 +410,12 @@ var TiledLayer = cc.Class({
},
/**
* Pointer to the map of tiles
* !#en Pointer to the map of tiles.
* !#zh 获取地图 tiles。
* @method getTiles
* @return {Array}
* @example
* var tiles = tiledLayer.getTiles();
*/
getTiles:function () {
if (this._sgNode) {
@@ -345,9 +425,12 @@ var TiledLayer = cc.Class({
},
/**
* Pointer to the map of tiles
* !#en Pointer to the map of tiles.
* !#zh 设置地图 tiles
* @method setTiles
* @param {Array} tiles
* @example
* tiledLayer.setTiles(tiles);
*/
setTiles:function (tiles) {
if (this._sgNode) {
@@ -356,9 +439,12 @@ var TiledLayer = cc.Class({
},
/**
* Tile set information for the layer
* !#en Tile set information for the layer.
* !#zh 获取 layer 的 Tileset 信息。
* @method getTileset
* @return {cc.TMXTilesetInfo}
* @return {TMXTilesetInfo}
* @example
* var tileset = tiledLayer.getTileset();
*/
getTileset:function () {
if (this._sgNode) {
@@ -368,9 +454,12 @@ var TiledLayer = cc.Class({
},
/**
* Tile set information for the layer
* !#en Tile set information for the layer.
* !#zh 设置 layer 的 Tileset 信息。
* @method setTileset
* @param {cc.TMXTilesetInfo} tileset
* @param {TMXTilesetInfo} tileset
* @example
* tiledLayer.getTileset(tileset);
*/
setTileset:function (tileset) {
if (this._sgNode) {
@@ -379,9 +468,13 @@ var TiledLayer = cc.Class({
},
/**
* Layer orientation, which is the same as the map orientation
* !#en Layer orientation, which is the same as the map orientation.
* !#zh 获取 Layer 方向(同地图方向)。
* @method getLayerOrientation
* @return {Number}
* @example
* var orientation = tiledLayer.getLayerOrientation();
* cc.log("Layer Orientation: " + orientation);
*/
getLayerOrientation:function () {
if (this._sgNode) {
@@ -391,9 +484,12 @@ var TiledLayer = cc.Class({
},
/**
* Layer orientation, which is the same as the map orientation
* !#en Layer orientation, which is the same as the map orientation.
* !#zh 设置 Layer 方向(同地图方向)。
* @method setLayerOrientation
* @param {Number} orientation
* @param {TiledMap.Orientation} orientation
* @example
* tiledLayer.setLayerOrientation(TiledMap.Orientation.ORTHO);
*/
setLayerOrientation:function (orientation) {
if (this._sgNode) {
@@ -402,9 +498,13 @@ var TiledLayer = cc.Class({
},
/**
* properties from the layer. They can be added using Tiled
* !#en properties from the layer. They can be added using Tiled.
* !#zh 获取 layer 的属性,可以使用 Tiled 编辑器添加属性。
* @method getProperties
* @return {Array}
* @example
* var properties = tiledLayer.getProperties();
* cc.log("Properties: " + properties);
*/
getProperties:function () {
if (this._sgNode) {
@@ -414,9 +514,12 @@ var TiledLayer = cc.Class({
},
/**
* properties from the layer. They can be added using Tiled
* !#en properties from the layer. They can be added using Tiled.
* !#zh 设置层属性。
* @method setProperties
* @param {Array} properties
* @example
* tiledLayer.setLayerOrientation(properties);
*/
setProperties:function (properties) {
if (this._sgNode) {
+111 -43
View File
@@ -24,13 +24,15 @@
****************************************************************************/
/**
* The orientation of tiled map
* !#en The orientation of tiled map.
* !#zh Tiled Map 地图方向。
* @enum TiledMap.Orientation
* @static
*/
var Orientation = cc.Enum({
/**
* Orthogonal orientation
* !#en Orthogonal orientation.
* !#zh 直角鸟瞰地图(90°地图)。
* @property ORTHO
* @type {Number}
* @static
@@ -38,7 +40,8 @@ var Orientation = cc.Enum({
ORTHO: 0,
/**
* Hexagonal orientation
* !#en Hexagonal orientation.
* !#zh 六边形地图
* @property HEX
* @type {Number}
* @static
@@ -46,7 +49,8 @@ var Orientation = cc.Enum({
HEX: 1,
/**
* Isometric orientation
* Isometric orientation.
* 等距斜视地图(斜45°地图)。
* @property ISO
* @type {Number}
* @static
@@ -54,8 +58,8 @@ var Orientation = cc.Enum({
ISO: 2
});
/**
* The property type of tiled map
/*
* The property type of tiled map.
* @enum TiledMap.Property
* @static
*/
@@ -103,8 +107,8 @@ var Property = cc.Enum({
TILE: 5
});
/**
* The tile flags of tiled map
/*
* The tile flags of tiled map.
* @enum TiledMap.TileFlag
* @static
*/
@@ -146,7 +150,8 @@ var TileFlag = cc.Enum({
});
/**
* Renders a TMX Tile Map in the scene.
* !#en Renders a TMX Tile Map in the scene.
* !#zh 在场景中渲染一个 tmx 格式的 Tile Map。
* @class TiledMap
* @extends Component
*/
@@ -177,8 +182,9 @@ var TiledMap = cc.Class({
},
/**
* The tmx file.
* @property {string} tmxFile
* !#en The tmx file.
* !#zh tmx 文件。
* @property {String} tmxFile
* @default ""
*/
_tmxFile: {
@@ -200,8 +206,9 @@ var TiledMap = cc.Class({
},
/**
* The event handler to be called when the map is loaded.
* @property {cc.Component.EventHandler} mapLoaded
* !#en The event handler to be called when the map is loaded.
* !#zh 在加载在地图时要调用的事件处理程序。
* @property {Component.EventHandler} mapLoaded
*/
mapLoaded: {
default: [],
@@ -210,96 +217,135 @@ var TiledMap = cc.Class({
},
/**
* Gets the map size.
* !#en Gets the map size.
* !#zh 获取地图大小。
* @method getMapSize
* @return {cc.Size}
* @return {Size}
* @example
* var mapSize = tiledMap.getMapSize();
* cc.log("Map Size: " + mapSize);
*/
getMapSize:function () {
return this._sgNode.getMapSize();
},
/**
* Set the map size.
* !#en Set the map size.
* !#zh 设置地图大小。
* @method setMapSize
* @param {cc.Size} mapSize
* @param {Size} mapSize
* @example
* tiledMap.setMapSize(new cc.size(960, 640));
*/
setMapSize:function (mapSize) {
this._sgNode.setMapSize(mapSize);
},
/**
* Gets the tile size.
* !#en Gets the tile size.
* !#zh 获取地图背景中 tile 元素的大小。
* @method getTileSize
* @return {cc.Size}
* @return {Size}
* @example
* var tileSize = tiledMap.getTileSize();
* cc.log("Tile Size: " + tileSize);
*/
getTileSize:function () {
return this._sgNode.getTileSize();
},
/**
* Set the tile size
* !#en Set the tile size.
* !#zh 设置地图背景中 tile 元素的大小。
* @method setTileSize
* @param {cc.Size} tileSize
* @param {Size} tileSize
* @example
* tiledMap.setTileSize(new cc.size(10, 10));
*/
setTileSize:function (tileSize) {
this._sgNode.setTileSize(tileSize);
},
/**
* map orientation
* !#en map orientation.
* !#zh 获取地图方向。
* @method getMapOrientation
* @return {Number}
* @example
* var mapOrientation = tiledMap.getMapOrientation();
* cc.log("Map Orientation: " + mapOrientation);
*/
getMapOrientation:function () {
return this._sgNode.getMapOrientation();
},
/**
* map orientation
* !#en map orientation.
* !#zh 设置地图方向。
* @method setMapOrientation
* @param {Number} orientation
* @param {TiledMap.Orientation} orientation
* @example
* tiledMap.setMapOrientation(TiledMap.Orientation.ORTHO);
*/
setMapOrientation:function (orientation) {
this._sgNode.setMapOrientation(orientation);
},
/**
* object groups
* !#en object groups.
* !#zh 获取所有的对象层。
* @method getObjectGroups
* @return {Array}
* @return {Object[]}
* @example
* var objGroups = titledMap.getObjectGroups();
* for (var i = 0; i < objGroups.length; ++i) {
* cc.log("obj: " + objGroups[i]);
* }
*/
getObjectGroups:function () {
return this._sgNode.getObjectGroups();
},
/**
* object groups
* !#en object groups.
* !#zh 设置所有的对象层。
* @method setObjectGroups
* @param {Array} groups
* @param {Object[]} groups
* @example
* titledMap.setObjectGroups(groups);
*/
setObjectGroups:function (groups) {
this._sgNode.setObjectGroups(groups);
},
/**
* Gets the map properties
* !#en Gets the map properties.
* !#zh 获取地图的属性。
* @method getProperties
* @return {object}
* @return {Object[]}
* @example
* var properties = titledMap.getProperties();
* for (var i = 0; i < properties.length; ++i) {
* cc.log("Properties: " + properties[i]);
* }
*/
getProperties:function () {
return this._sgNode.getProperties();
},
/**
* Set the map properties
* !#en Set the map properties.
* !#zh 设置地图的属性。
* @method setProperties
* @param {object} properties
* @param {Object[]} properties
* @example
* titledMap.setProperties(properties);
*/
setProperties:function (properties) {
this._sgNode.setProperties(properties);
},
/**
/*
* Initializes the instance of cc.TiledMap with tmxFile.
* The mapLoaded events will be emitted when the map is loaded.
* @method initWithTMXFile
@@ -309,7 +355,7 @@ var TiledMap = cc.Class({
this._tmxFile = tmxFile;
},
/**
/*
* Initializes the instance of cc.TiledMap with tmxString.
* The mapLoaded events will be emitted when the map is loaded.
* @method initWithXML
@@ -350,9 +396,15 @@ var TiledMap = cc.Class({
},
/**
* Return All layers array.
* !#en Return All layers array.
* !#zh 返回包含所有 layer 的数组。
* @method allLayers
* @returns {Array}
* @returns {Node[]}
* @example
* var layers = titledMap.allLayers();
* for (var i = 0; i < layers.length; ++i) {
* cc.log("Layers: " + layers[i]);
* }
*/
allLayers: function () {
var logicChildren = this.node.children;
@@ -369,10 +421,14 @@ var TiledMap = cc.Class({
},
/**
* return the cc.TiledLayer for the specific layer
* !#en return the cc.TiledLayer for the specific layer.
* !#zh 获取指定名称的 layer。
* @method getLayer
* @param {String} layerName
* @return {cc.TiledLayer}
* @return {TiledLayer}
* @example
* var layer = titledMap.getLayer("Player");
* cc.log(layer);
*/
getLayer:function (layerName) {
var logicChildren = this.node.children;
@@ -388,30 +444,42 @@ var TiledMap = cc.Class({
},
/**
* Return the TMXObjectGroup for the specific group
* !#en Return the TMXObjectGroup for the specific group.
* !#zh 获取指定的 TMXObjectGroup。
* @method getObjectGroup
* @param {String} groupName
* @return {cc.TMXObjectGroup}
* @return {TMXObjectGroup}
* @example
* var group = titledMap.getObjectGroup("Players");
* cc.log("ObjectGroup: " + group);
*/
getObjectGroup:function (groupName) {
return this._sgNode.getObjectGroup(groupName);
},
/**
* Return the value for the specific property name
* !#en Return the value for the specific property name.
* !#zh 通过属性名称,获取指定的属性。
* @method getProperty
* @param {String} propertyName
* @return {String}
* @example
* var property = titledMap.getProperty("info");
* cc.log("Property: " + property);
*/
getProperty:function (propertyName) {
return this._sgNode.getProperty(propertyName);
},
/**
* Return properties dictionary for tile GID
* !#en Return properties dictionary for tile GID.
* !#zh 通过 GID ,获取指定的属性。
* @method getPropertiesForGID
* @param {Number} GID
* @return {object}
* @return {Object}
* @example
* var properties = titledMap.getPropertiesForGID(GID);
* cc.log("Properties: " + properties);
*/
getPropertiesForGID: function(GID) {
return this._sgNode.getPropertiesForGID(GID);
+8 -3
View File
@@ -39,9 +39,10 @@ proto.rendering = function (ctx) {
var node = this._node, tmpQuad = this._tmpQuad;
var color = node.getColor(), locSkeleton = node._skeleton;
var blendMode, textureAtlas, attachment, slot, i, n;
var textureAtlas, attachment, slot, i, n;
var locBlendFunc = node._blendFunc;
var premultiAlpha = node._premultipliedAlpha;
var blendMode = -1;
this._shaderProgram.use();
this._shaderProgram._setUniformForMVPMatrixWithMat4(this._stackMatrix);
@@ -78,13 +79,16 @@ proto.rendering = function (ctx) {
var regionTextureAtlas = node.getTextureAtlas(attachment);
if (slot.data.blendMode != blendMode) {
if (slot.data.blendMode !== blendMode) {
if (textureAtlas) {
textureAtlas.drawQuads();
textureAtlas.removeAllQuads();
}
blendMode = slot.data.blendMode;
switch (blendMode) {
case spine.BlendMode.normal:
cc.gl.blendFunc(premultiAlpha ? cc.macro.ONE : cc.macro.SRC_ALPHA, cc.macro.ONE_MINUS_SRC_ALPHA);
break;
case spine.BlendMode.additive:
cc.gl.blendFunc(premultiAlpha ? cc.macro.ONE : cc.macro.SRC_ALPHA, cc.macro.ONE);
break;
@@ -97,7 +101,8 @@ proto.rendering = function (ctx) {
default:
cc.gl.blendFunc(locBlendFunc.src, locBlendFunc.dst);
}
} else if (regionTextureAtlas != textureAtlas && textureAtlas) {
}
else if (regionTextureAtlas !== textureAtlas && textureAtlas) {
textureAtlas.drawQuads();
textureAtlas.removeAllQuads();
}
+124 -53
View File
@@ -38,11 +38,18 @@ function setEnumAttr (obj, propName, enumDef) {
}
/**
* !#en
* The skeleton of Spine <br/>
* <br/>
* (Skeleton has a reference to a SkeletonData and stores the state for skeleton instance,
* which consists of the current pose's bone SRT, slot colors, and which slot attachments are visible. <br/>
* Multiple skeletons can use the same SkeletonData which includes all animations, skins, and attachments.) <br/>
* !#zh
* Spine 骨骼动画 <br/>
* <br/>
* (Skeleton 具有对骨骼数据的引用并且存储了骨骼实例的状态,
* 它由当前的骨骼动作,slot 颜色,和可见的 slot attachments 组成。<br/>
* 多个 Skeleton 可以使用相同的骨骼数据,其中包括所有的动画,皮肤和 attachments。
*
* @class Skeleton
* @extends cc._RendererUnderSG
@@ -63,9 +70,14 @@ sp.Skeleton = cc.Class({
properties: {
/**
* !#en
* The skeleton data contains the skeleton information (bind pose bones, slots, draw order,
* attachments, skins, etc) and animations but does not hold any state.
* attachments, skins, etc) and animations but does not hold any state.<br/>
* Multiple skeletons can share the same skeleton data.
* !#zh
* 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序,
* attachments,皮肤等等)和动画但不持有任何状态。<br/>
* 多个 Skeleton 可以共用相同的骨骼数据。
* @property {SkeletonData} skeletonData
*/
skeletonData: {
@@ -95,8 +107,9 @@ sp.Skeleton = cc.Class({
// 由于 spine 的 skin 是无法二次替换的,所以只能设置默认的 skin
/**
* The name of default skin.
* @property {string} defaultSkin
* !#en The name of default skin.
* !#zh 默认的皮肤名称。
* @property {String} defaultSkin
*/
defaultSkin: {
default: '',
@@ -104,8 +117,9 @@ sp.Skeleton = cc.Class({
},
/**
* The name of default animation.
* @property {string} defaultAnimation
* !#en The name of default animation.
* !#zh 默认的动画名称。
* @property {String} defaultAnimation
*/
defaultAnimation: {
default: '',
@@ -113,8 +127,9 @@ sp.Skeleton = cc.Class({
},
/**
* The name of current playing animation.
* @property {string} animation
* !#en The name of current playing animation.
* !#zh 当前播放的动画名称。
* @property {String} animation
*/
animation: {
get: function () {
@@ -135,7 +150,7 @@ sp.Skeleton = cc.Class({
},
/**
* @property {number} _defaultSkinIndex
* @property {Number} _defaultSkinIndex
*/
_defaultSkinIndex: {
get: function () {
@@ -233,7 +248,9 @@ sp.Skeleton = cc.Class({
//},
/**
* @property {boolean} loop
* !#en TODO
* !#zh 是否循环播放当前骨骼动画。
* @property {Boolean} loop
* @default true
*/
loop: {
@@ -244,8 +261,9 @@ sp.Skeleton = cc.Class({
/**
* The time scale of this skeleton.
* @property {number} timeScale
* !#en The time scale of this skeleton.
* !#zh 当前骨骼中所有动画的时间缩放率。
* @property {Number} timeScale
* @default 1
*/
timeScale: {
@@ -259,8 +277,9 @@ sp.Skeleton = cc.Class({
},
/**
* Indicates whether open debug slots.
* @property {boolean} debugSlots
* !#en Indicates whether open debug slots.
* !#zh 是否显示 slot 的 debug 信息。
* @property {Boolean} debugSlots
* @default false
*/
debugSlots: {
@@ -275,8 +294,9 @@ sp.Skeleton = cc.Class({
},
/**
* Indicates whether open debug bones.
* @property {boolean} debugBones
* !#en Indicates whether open debug bones.
* !#zh 是否显示 bone 的 debug 信息。
* @property {Boolean} debugBones
* @default false
*/
debugBones: {
@@ -384,7 +404,8 @@ sp.Skeleton = cc.Class({
// RENDERER
/**
* Sets the bones and slots to the setup pose.
* !#en Sets the bones and slots to the setup pose.
* !#zh 还原到起始动作
* @method setToSetupPose
*/
setToSetupPose: function () {
@@ -394,7 +415,12 @@ sp.Skeleton = cc.Class({
},
/**
* Sets the bones to the setup pose, using the values from the `BoneData` list in the `SkeletonData`.
* !#en
* Sets the bones to the setup pose,
* using the values from the `BoneData` list in the `SkeletonData`.
* !#zh
* 设置 bone 到起始动作
* 使用 SkeletonData 中的 BoneData 列表中的值。
* @method setBonesToSetupPose
*/
setBonesToSetupPose: function () {
@@ -404,7 +430,12 @@ sp.Skeleton = cc.Class({
},
/**
* Sets the slots to the setup pose, using the values from the `SlotData` list in the `SkeletonData`.
* !#en
* Sets the slots to the setup pose,
* using the values from the `SlotData` list in the `SkeletonData`.
* !#zh
* 设置 slot 到起始动作。
* 使用 SkeletonData 中的 SlotData 列表中的值。
* @method setSlotsToSetupPose
*/
setSlotsToSetupPose: function () {
@@ -414,9 +445,14 @@ sp.Skeleton = cc.Class({
},
/**
* Finds a bone by name. This does a string comparison for every bone.
* !#en
* Finds a bone by name.
* This does a string comparison for every bone.
* !#zh
* 通过名称查找 bone。
* 这里对每个 bone 的名称进行了对比。
* @method findBone
* @param {string} boneName
* @param {String} boneName
* @return {spine.Bone}
*/
findBone: function (boneName) {
@@ -427,9 +463,14 @@ sp.Skeleton = cc.Class({
},
/**
* Finds a slot by name. This does a string comparison for every slot.
* !#en
* Finds a slot by name.
* This does a string comparison for every slot.
* !#zh
* 通过名称查找 slot。
* 这里对每个 slot 的名称进行了比较。
* @method findSlot
* @param {string} slotName
* @param {String} slotName
* @return {spine.Slot}
*/
findSlot: function (slotName) {
@@ -440,9 +481,16 @@ sp.Skeleton = cc.Class({
},
/**
* Finds a skin by name and makes it the active skin. This does a string comparison for every skin. Note that setting the skin does not change which attachments are visible.
* !#en
* Finds a skin by name and makes it the active skin.
* This does a string comparison for every skin.
* Note that setting the skin does not change which attachments are visible.
* !#zh
* 按名称查找皮肤,激活该皮肤。
* 这里对每个皮肤的名称进行了比较。
* 注意:设置皮肤不会改变 attachment 的可见性。。
* @method setSkin
* @param {string} skinName
* @param {String} skinName
* @return {spine.Skin}
*/
setSkin: function (skinName) {
@@ -453,10 +501,15 @@ sp.Skeleton = cc.Class({
},
/**
* Returns the attachment for the slot and attachment name. The skeleton looks first in its skin, then in the skeleton data’s default skin.
* !#en
* Returns the attachment for the slot and attachment name.
* The skeleton looks first in its skin, then in the skeleton data’s default skin.
* !#zh
* 通过 slot 和 attachment 的名称获取 attachment。
* Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
* @method getAttachment
* @param {string} slotName
* @param {string} attachmentName
* @param {String} slotName
* @param {String} attachmentName
* @return {spine.RegionAttachment|sp.spine.BoundingBoxAttachment}
*/
getAttachment: function (slotName, attachmentName) {
@@ -467,10 +520,15 @@ sp.Skeleton = cc.Class({
},
/**
* Sets the attachment for the slot and attachment name. The skeleton looks first in its skin, then in the skeleton data’s default skin.
* !#en
* Sets the attachment for the slot and attachment name.
* The skeleton looks first in its skin, then in the skeleton data’s default skin.
* !#zh
* 通过 slot 和 attachment 的名字来设置 attachment。
* Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
* @method setAttachment
* @param {string} slotName
* @param {string} attachmentName
* @param {String} slotName
* @param {String} attachmentName
*/
setAttachment: function (slotName, attachmentName) {
if (this._sgNode) {
@@ -479,7 +537,8 @@ sp.Skeleton = cc.Class({
},
/**
* Sets skeleton data to sp.Skeleton.
* !#en Sets skeleton data to sp.Skeleton.
* !#zh 设置 Skeleton 中的 Skeleton Data。
* @method setSkeletonData
* @param {spine.SkeletonData} skeletonData
* @param {spine.SkeletonData} ownsSkeletonData
@@ -505,7 +564,8 @@ sp.Skeleton = cc.Class({
// ANIMATION
/**
* Sets animation state data.
* !#en Sets animation state data.
* !#zh 设置动画状态数据。
* @method setAnimationStateData
* @param {spine.AnimationStateData} stateData
*/
@@ -516,11 +576,14 @@ sp.Skeleton = cc.Class({
},
/**
* Mix applies all keyframe values, interpolated for the specified time and mixed with the current values.
* !#en
* Mix applies all keyframe values,
* interpolated for the specified time and mixed with the current values.
* !#zh 为所有关键帧设定混合及混合时间(从当前值开始差值)。
* @method setMix
* @param {string} fromAnimation
* @param {string} toAnimation
* @param {number} duration
* @param {String} fromAnimation
* @param {String} toAnimation
* @param {Number} duration
*/
setMix: function (fromAnimation, toAnimation, duration) {
if (this._sgNode) {
@@ -529,10 +592,11 @@ sp.Skeleton = cc.Class({
},
/**
* Sets event listener.
* !#en Sets event listener.
* !#zh 设置动画事件监听器。
* @method setAnimationListener
* @param {object} target
* @param {function} callback
* @param {Object} target
* @param {Function} callback
*/
setAnimationListener: function (target, callback) {
if (this._sgNode) {
@@ -541,11 +605,12 @@ sp.Skeleton = cc.Class({
},
/**
* Set the current animation. Any queued animations are cleared.
* !#en Set the current animation. Any queued animations are cleared.
* !#zh 设置当前动画。队列中的任何的动画将被清除。
* @method setAnimation
* @param {number} trackIndex
* @param {string} name
* @param {boolean} loop
* @param {Number} trackIndex
* @param {String} name
* @param {Boolean} loop
* @return {spine.TrackEntry}
*/
setAnimation: function (trackIndex, name, loop) {
@@ -567,12 +632,13 @@ sp.Skeleton = cc.Class({
},
/**
* Adds an animation to be played delay seconds after the current or last queued animation.
* !#en Adds an animation to be played delay seconds after the current or last queued animation.
* !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。
* @method addAnimation
* @param {number} trackIndex
* @param {string} name
* @param {boolean} loop
* @param {number} [delay=0]
* @param {Number} trackIndex
* @param {String} name
* @param {Boolean} loop
* @param {Number} [delay=0]
* @return {spine.TrackEntry}
*/
addAnimation: function (trackIndex, name, loop, delay) {
@@ -583,7 +649,8 @@ sp.Skeleton = cc.Class({
},
/**
* Returns track entry by trackIndex.
* !#en Returns track entry by trackIndex.
* !#zh 通过 track 索引获取 TrackEntry。
* @method getCurrent
* @param trackIndex
* @return {spine.TrackEntry}
@@ -596,7 +663,8 @@ sp.Skeleton = cc.Class({
},
/**
* Clears all tracks of animation state.
* !#en Clears all tracks of animation state.
* !#zh 清除所有 track 的动画状态。
* @method clearTracks
*/
clearTracks: function () {
@@ -606,7 +674,8 @@ sp.Skeleton = cc.Class({
},
/**
* Clears track of animation state by trackIndex.
* !#en Clears track of animation state by trackIndex.
* !#zh 清除出指定 track 的动画状态。
* @method clearTrack
* @param {number} trackIndex
*/
@@ -658,7 +727,8 @@ sp.Skeleton = cc.Class({
},
/**
* Set the start event listener.
* !#en Set the start event listener.
* !#zh 用来设置开始播放动画的事件监听。
* @method setStartListener
* @param {function} listener
*/
@@ -669,7 +739,8 @@ sp.Skeleton = cc.Class({
},
/**
* Set the end event listener.
* !#en Set the end event listener.
* !#zh 用来设置动画播放完后的事件监听。
* @method setEndListener
* @param {function} listener
*/
+14 -11
View File
@@ -73,8 +73,8 @@ var TextureLoader = cc.Class({
});
/**
* The skeleton data of spine.
*
* !#en The skeleton data of spine.
* !#zh Spine 的 骨骼数据。
* @class SkeletonData
* @extends cc.Asset
*/
@@ -91,8 +91,9 @@ var SkeletonData = cc.Class({
_skeletonJson: null,
/**
* See http://en.esotericsoftware.com/spine-json-format
* @property {object} skeletonJson
* !#en See http://en.esotericsoftware.com/spine-json-format
* !#zh 可查看 Spine 官方文档 http://zh.esotericsoftware.com/spine-json-format
* @property {Object} skeletonJson
*/
skeletonJson: {
get: function () {
@@ -107,7 +108,7 @@ var SkeletonData = cc.Class({
_atlasText: "",
/**
* @property {string} atlasText
* @property {String} atlasText
*/
atlasText: {
get: function () {
@@ -127,7 +128,7 @@ var SkeletonData = cc.Class({
// -------------------------------------------------
/**
* @property {cc.Texture2D} textures
* @property {Texture2D} textures
*/
textures: {
default: [],
@@ -135,15 +136,16 @@ var SkeletonData = cc.Class({
},
/**
* !#en
* A scale can be specified on the JSON or binary loader which will scale the bone positions,
* image sizes, and animation translations.
* This can be useful when using different sized images than were used when designing the skeleton
* in Spine. For example, if using images that are half the size than were used in Spine,
* a scale of 0.5 can be used. This is commonly used for games that can run with either low or high
* resolution texture atlases.
*
* @see http://en.esotericsoftware.com/spine-using-runtimes#Scaling
* @property {number} scale
* see http://en.esotericsoftware.com/spine-using-runtimes#Scaling
* !#zh 可查看 Spine 官方文档: http://zh.esotericsoftware.com/spine-using-runtimes#Scaling
* @property {Number} scale
*/
scale: 1
},
@@ -181,9 +183,10 @@ var SkeletonData = cc.Class({
},
/**
* Get the included SkeletonData used in spine runtime.
* !#en Get the included SkeletonData used in spine runtime.
* !#zh 获取 Spine Runtime 使用的 SkeletonData。
* @method getRuntimeData
* @param {boolean} [quiet=false]
* @param {Boolean} [quiet=false]
* @return {spine.SkeletonData}
*/
getRuntimeData: !CC_JSB && function (quiet) {
+11 -2
View File
@@ -23,7 +23,12 @@
****************************************************************************/
/**
* The global main namespace of Spine, all classes, functions, properties and constants of Spine are defined in this namespace
* !#en
* The global main namespace of Spine, all classes, functions,
* properties and constants of Spine are defined in this namespace
* !#zh
* Spine 的全局的命名空间,
* 与 Spine 相关的所有的类,函数,属性,常量都在这个命名空间中定义。
* @module sp
* @main sp
*/
@@ -97,8 +102,12 @@ if (!CC_EDITOR || !Editor.isCoreLevel) {
if (!CC_JSB) {
/**
* The official spine runtime.
* !#en
* The official spine runtime.<br/>
* See http://en.esotericsoftware.com/spine-using-runtimes
* !#zh
* 官方 Spine Runtime。<br/>
* 可查看 Spine 官方文档 http://en.esotericsoftware.com/spine-using-runtimes
* @property {object} spine
*/
sp.spine = require('./lib/spine');
+5
View File
@@ -208,6 +208,11 @@ window.clearInterval = function (intervalId) {
};
window.clearTimeout = clearInterval;
// SocketIO
if (window.SocketIO) {
window.io = window.SocketIO;
}
// ccsg
window._ccsg = {
Node: cc.Node,