diff --git a/CCDebugger.js b/CCDebugger.js
index 659e92f042..d0bd9a45b9 100644
--- a/CCDebugger.js
+++ b/CCDebugger.js
@@ -405,6 +405,10 @@ cc._initDebugSetting = function (mode) {
} else if(console && console.log.apply){//console is null when user doesn't open dev tool on IE9
//log to console
+ // For JSB
+ if (!console.error) console.error = console.log;
+ if (!console.warn) console.warn = console.log;
+
/**
* Outputs an error message to the Fireball Console (editor) or Web Console (runtime).
* - In Fireball, error is red.
diff --git a/cocos2d/ToMerge/wrappers/bitmap-font.js b/cocos2d/ToMerge/wrappers/bitmap-font.js
deleted file mode 100644
index f9a228966d..0000000000
--- a/cocos2d/ToMerge/wrappers/bitmap-font.js
+++ /dev/null
@@ -1,177 +0,0 @@
-
-var TextAlign = cc.TextAlignment;
-
-/**
- * Enum for text anchor
- * @readOnly
- * @enum {number}
- */
-var TextAnchor = cc.Enum({
- TopLeft: -1,
- TopCenter: -1,
- TopRight: -1,
- MiddleLeft: -1,
- MiddleCenter: -1,
- MiddleRight: -1,
- BottomLeft: -1,
- BottomCenter: -1,
- BottomRight: -1,
-});
-
-cc._TextAnchor = TextAnchor;
-
-var getAnchorPoint = (function () {
- var Anchor2Point = new Array(TextAnchor.BottomRight + 1);
- Anchor2Point[TextAnchor.TopLeft] = cc.p(0, 1);
- Anchor2Point[TextAnchor.TopCenter] = cc.p(0.5, 1);
- Anchor2Point[TextAnchor.TopRight] = cc.p(1, 1);
- Anchor2Point[TextAnchor.MiddleLeft] = cc.p(0, 0.5);
- Anchor2Point[TextAnchor.MiddleCenter] = cc.p(0.5, 0.5);
- Anchor2Point[TextAnchor.MiddleRight] = cc.p(1, 0.5);
- Anchor2Point[TextAnchor.BottomLeft] = cc.p(0, 0);
- Anchor2Point[TextAnchor.BottomCenter] = cc.p(0.5, 0);
- Anchor2Point[TextAnchor.BottomRight] = cc.p(1, 0);
-
- return (function (textAnchor) {
- var anchorPoint = Anchor2Point[textAnchor];
- return cc.p(anchorPoint);
- });
-})();
-
-
-var NodeWrapper = require('./node');
-
-var BitmapFontWrapper = cc.Class({
- name: 'cc.BitmapFontWrapper',
- extends: NodeWrapper,
-
- ctor: function () {
- },
-
- properties: {
-
- bitmapFont: {
- get: function () {
- return this.targetN._fntFile || '';
- },
- set: function (value) {
- this.targetN._fntFile = value;
-
- this.onBeforeSerialize();
- this.createNode(this.targetN);
- },
- url: cc.BitmapFont
- },
-
- text: {
- get: function () {
- return this.targetN.string;
- },
- set: function ( value ) {
- if (typeof value === 'string') {
- this.targetN.string = value;
- }
- else {
- cc.error('The new text must be string');
- }
- }
- },
-
- anchor: {
- get: function () {
- return this._anchor;
- },
- set: function ( value ) {
- if (typeof value === 'number') {
- this._anchor = value;
-
- var anchorPoint = getAnchorPoint(value);
- this.targetN.setAnchorPoint( anchorPoint );
- }
- else {
- cc.error('The new text must be number');
- }
- },
- type: TextAnchor
- },
-
- align: {
- get: function () {
- // jsb not implement yet
- if (typeof jsb !== 'undefined') return TextAlign.Left;
-
- return this.targetN.textAlign;
- },
- set: function ( value ) {
- if (typeof value === 'number') {
- this.targetN.textAlign = value;
- }
- else {
- cc.error('The new text must be number');
- }
- },
- type: TextAlign
- },
-
- childrenN: {
- get: function () {
- return [];
- },
- },
-
-
- _text: {
- default: ""
- },
-
- _anchor: {
- default: TextAnchor.MiddleCenter
- },
-
- _align: {
- default: TextAlign.Left
- },
-
- _bitmapFont: {
- default: '',
- url: cc.BitmapFont
- }
- },
-
- onBeforeSerialize: function () {
- NodeWrapper.prototype.onBeforeSerialize.call(this);
-
- this._text = this.text;
- this._anchor = this.anchor;
- this._align = this.align;
- this._bitmapFont = this.bitmapFont;
- },
-
- createNode: function (node) {
- node = node || new cc.LabelBMFont();
-
- var bitmapFontUrl = this._bitmapFont;
-
- if ( bitmapFontUrl ) {
- node._fntFile = bitmapFontUrl;
- cc.loader.load( bitmapFontUrl, function (err, results) {
- node.initWithString(this._text, bitmapFontUrl);
- node.setAnchorPoint( getAnchorPoint(this._anchor) );
- node.textAlign = this._align;
-
- NodeWrapper.prototype.createNode.call(this, node);
- }.bind(this));
- }
- else {
- node.string = this._text;
- node.setAnchorPoint( getAnchorPoint(this._anchor) );
- node.textAlign = this._align;
-
- NodeWrapper.prototype.createNode.call(this, node);
- }
-
- return node;
- }
-});
-
-cc.BitmapFontWrapper = module.exports = BitmapFontWrapper;
diff --git a/cocos2d/ToMerge/wrappers/edit-box.js b/cocos2d/ToMerge/wrappers/edit-box.js
deleted file mode 100644
index e1834fd475..0000000000
--- a/cocos2d/ToMerge/wrappers/edit-box.js
+++ /dev/null
@@ -1,250 +0,0 @@
-var Vec2 = cc.Vec2;
-
-var NodeWrapper = require('./node');
-
-var EditBoxWrapper = cc.Class({
- name: 'cc.EditBoxWrapper',
- extends: NodeWrapper,
-
- properties: {
- normalBackground: {
- default: '',
- url: cc.Texture2D,
-
- notify: function() {
- if (!this.targetN) {
- return;
- }
- var value = this.normalBackground;
- var normalScale9Sprite = new cc.Scale9Sprite(value);
- normalScale9Sprite.setPreferredSize(this.targetN.getContentSize());
- var oldPosition = this.targetN.getPosition();
-
- this.targetN.initWithSizeAndBackgroundSprite(this.targetN.getContentSize(), normalScale9Sprite);
- this.targetN.setPosition(oldPosition);
- }
- },
- childrenN: {
- get: function() {
- return [];
- }
- },
- size: {
- get: function() {
- var size = this.targetN.getPreferredSize();
- return new Vec2(size.width, size.height);
- },
-
- set: function(value) {
- if (value instanceof Vec2) {
- this.targetN.setPreferredSize(cc.size(value.x, value.y));
- } else {
- cc.error('The value must be cc.Vec2 -> size.');
- }
- }
- },
- _placeholder: {
- default: 'input your text here'
- },
- placeholder: {
- get: function() {
- return this.targetN.getPlaceHolder();
- },
- set: function(value) {
- if (typeof value === 'string') {
- this.targetN.setPlaceHolder(value);
- } else {
- cc.error('The value must be string -> placeholder');
- }
- }
- },
- text: {
- get: function() {
- return this.targetN.getString();
- },
- set: function(value) {
- if (typeof value === 'string') {
- this.targetN.setString(value);
- } else {
- cc.error('The value must be string -> text.');
- }
- }
- },
- _text: {
- default: ''
- },
- fontColor: {
- default: cc.Color.WHITE,
- type: cc.Color,
-
- notify: function() {
- if (!this.targetN) return;
-
- var value = this.fontColor;
- if (value instanceof cc.Color) {
- this.targetN.setFontColor(value);
- } else {
- cc.error('The value must be cc.Color -> fontColor.');
- }
- }
- },
- fontName: {
- default: 'Arial',
-
- notify: function() {
- if (!this.targetN) return;
-
- var value = this.fontName;
- if (typeof value === 'string') {
- this.targetN.setFontName(value);
- } else {
- cc.error('The value must be a string -> fontName.');
- }
- }
- },
- fontSize: {
- default: 14,
-
- notify: function() {
- if (!this.targetN) return;
-
- var value = this.fontSize;
- if (!isNaN(value)) {
- this.targetN.setFontSize(value);
- } else {
- cc.error('The value is NaN.');
- }
- }
- },
- placeholderColor: {
- default: cc.Color.WHITE,
- type: cc.Color,
-
- notify: function() {
- if (!this.targetN) return;
-
- var value = this.placeholderColor;
- if (value instanceof cc.Color) {
- this.targetN.setPlaceholderFontColor(value);
- } else {
- cc.error('The value must be cc.Color -> placeholderColor.');
- }
- }
- },
- placeholderSize: {
- default: 12,
-
- notify: function() {
- if (!this.targetN) return;
-
- var value = this.placeholderSize;
- if (!isNaN(value)) {
- this.targetN.setPlaceholderFontSize(value);
- } else {
- cc.error('The value is NaN!');
- }
- }
- },
- maxLength: {
- get: function() {
- return this.targetN.getMaxLength();
- },
- set: function(value) {
- if (!isNaN(value)) {
- this.targetN.setMaxLength(value);
- } else {
- cc.error('The value is NaN!');
- }
- }
- },
- _maxLength: {
- default: 50
- },
- inputMode: {
- default: cc.EditBox.InputMode.ANY,
- type: cc.EditBox.InputMode,
- notify: function() {
- if (!this.targetN) return;
-
- var value = this.inputMode;
- if (!isNaN(value)) {
- this.targetN.setInputMode(value);
- } else {
- cc.error('The value must be cc.EditBox.InputMode -> inputMode.');
- }
- }
- },
- inputFlag: {
- default: cc.EditBox.InputFlag.SENSITIVE,
- type: cc.EditBox.InputFlag,
- notify: function() {
- if (!this.targetN) return;
-
- var value = this.inputFlag;
- if (!isNaN(value)) {
- this.targetN.setInputFlag(value);
- } else {
- cc.error('The value must be cc.EditBox.InputFlag -> inputFlag.');
- }
- }
- },
- keyboardType: {
- default: cc.KeyboardReturnType.DEFAULT,
- type: cc.KeyboardReturnType,
- notify: function() {
- if (!this.targetN) return;
-
- var value = this.keyboardType;
- if (!isNaN(value)) {
- this.targetN.setReturnType(value);
- } else {
- cc.error('The value must be cc.KeyboardReturnType -> keyboardType.');
- }
- }
-
- }
- },
- onBeforeSerialize: function() {
- NodeWrapper.prototype.onBeforeSerialize.call(this);
-
- this._text = this.text;
- this._placeholder = this.placeholder;
- this._maxLength = this.maxLength;
- },
-
- createNode: function(node) {
- var contentSize;
- if (this._size) {
- contentSize = cc.size(this._size[0], this._size[1]);
- } else {
- contentSize = cc.size(100, 50);
- }
-
- var normalScale9Sprite;
- if (this.normalBackground) {
- normalScale9Sprite = new cc.Scale9Sprite(this.normalBackground);
- } else {
- normalScale9Sprite = new cc.Scale9Sprite();
- }
-
- node = node || new cc.EditBox(contentSize, normalScale9Sprite, new cc.Scale9Sprite(), new cc.Scale9Sprite());
- NodeWrapper.prototype.createNode.call(this, node);
-
- node.setPreferredSize(contentSize);
- node.setString(this._text);
- node.setFontColor(this.fontColor);
- node.setFontSize(this.fontSize);
- node.setFontName(this.fontName);
- node.setPlaceHolder(this._placeholder);
- node.setPlaceholderFontSize(this.placeholderSize);
- node.setPlaceholderFontColor(this.placeholderColor);
- node.setMaxLength(this._maxLength);
- node.setInputMode(this.inputMode);
- node.setInputFlag(this.inputFlag);
- node.setReturnType(this.keyboardType);
-
- return node;
- }
-});
-
-cc.EditBoxWrapper = module.exports = EditBoxWrapper;
diff --git a/cocos2d/ToMerge/wrappers/index.js b/cocos2d/ToMerge/wrappers/index.js
deleted file mode 100644
index 0ca4abc428..0000000000
--- a/cocos2d/ToMerge/wrappers/index.js
+++ /dev/null
@@ -1,27 +0,0 @@
-module.exports = [
- [cc, 'Node', require('./node'), 'Node'],
- [cc, 'SpriteBatchNode',require('./sprite-batch-node'), 'SpriteBatchNode'],
- [cc, 'LabelBMFont', require('./bitmap-font'), 'LabelBMFont'],
- [cc, 'LabelTTF', require('./label-ttf'), 'LabelTTF'],
- [cc, 'ParticleSystem', require('./particle'), 'ParticleSystem'],
- [cc, 'ProgressTimer', require('./progress-timer'), 'ProgressTimer'],
- [cc, 'TMXTiledMap', require('./tiled-map')],
- [cc, 'Layer', require('./layer'), 'Layer'],
- [cc, 'LayerColor', require('./layer-color'), 'LayerColor'],
- [cc, 'DrawNode', require('./draw-node'), 'DrawNode'],
- [cc, 'EditBox', require('./edit-box'), 'EditBox'],
-
- [ccui, 'Button', require('./ui/button'), 'UI/Button'],
- [ccui, 'ImageView', require('./ui/scale9-sprite'),'UI/Scale9Sprite'],
- [ccui, 'CheckBox', require('./ui/check-box'), 'UI/CheckBox'],
- [ccui, 'LoadingBar', require('./ui/loading-bar'), 'UI/LoadingBar'],
- [ccui, 'Slider', require('./ui/slider'), 'UI/Slider'],
- [ccui, 'ScrollView', require('./ui/scroll-view'), 'UI/ScrollView'],
- [ccui, 'ListView', require('./ui/list-view'), 'UI/ListView'],
- [ccui, 'PageView', require('./ui/page-view'), 'UI/PageView'],
- [ccui, 'Layout', require('./ui/layout'), 'UI/Layout'],
- [ccui, 'Text', require('./ui/text'), 'UI/Text'],
- [ccui, 'TextField', require('./ui/text-field'), 'UI/TextField'],
- [ccui, 'TextAtlas', require('./ui/text-atlas'), 'UI/TextAtlas'],
- [ccui, 'TextBMFont', require('./ui/text-bitmap-font'), 'UI/TextBMFont'],
-];
diff --git a/cocos2d/ToMerge/wrappers/label-ttf.js b/cocos2d/ToMerge/wrappers/label-ttf.js
deleted file mode 100644
index 28b6f76f8c..0000000000
--- a/cocos2d/ToMerge/wrappers/label-ttf.js
+++ /dev/null
@@ -1,202 +0,0 @@
-var Utils = require('./utils');
-var NodeWrapper = require('./node');
-
-var LabelTTFWrapper = cc.Class({
- name: 'cc.LabelTTFWrapper',
- extends: NodeWrapper,
-
- properties: {
-
- text: {
- get: function () {
- return this.targetN.string;
- },
- set: function (value) {
- if (typeof value === 'string') {
- this.targetN.string = value;
- }
- else {
- cc.error('The new text must be String');
- }
- }
- },
-
- fontSize: {
- get: function () {
- return this.targetN.fontSize;
- },
- set: function (value) {
- if ( !isNaN(value) ) {
- this.targetN.fontSize = value;
- }
- else {
- cc.error('The new fontSize must not be NaN');
- }
- }
- },
-
- font: {
- default: null,
- type: cc.TTFFont,
-
- notify: function () {
- if ( !this.targetN ) return;
-
- var value = this.font;
- if (!value || value instanceof cc.TTFFont) {
- Utils.setFontToNode(value, this.targetN);
- }
- else {
- cc.error('The new font must be cc.TTFFont');
- }
- }
- },
-
- fontFamily: {
- get: function () {
- return this.targetN.fontName;
- },
- set: function (value) {
- if (typeof value === 'string') {
- this.targetN.fontName = value;
- }
- else {
- cc.error('The new fontFamily must be String');
- }
- }
- },
-
- align: {
- get: function () {
- return this.targetN.textAlign;
- },
- set: function ( value ) {
- if (typeof value === 'number') {
- this.targetN.textAlign = value;
- }
- else {
- cc.error('The new textAlign must be number');
- }
- },
- type: cc.TextAlignment
- },
-
- verticalAlign: {
- get: function () {
- return this.targetN.verticalAlign;
- },
- set: function ( value ) {
- if (typeof value === 'number') {
- this.targetN.verticalAlign = value;
- }
- else {
- cc.error('The new verticalAlign must be number');
- }
- },
- type: cc.VerticalTextAlignment
- },
-
- boundingBox: {
- get: function () {
- var target = this.targetN;
- return new cc.Vec2(target.boundingWidth, target.boundingHeight);
- },
- set: function (value) {
- if (value instanceof cc.Vec2) {
- this.targetN.boundingWidth = value.x;
- this.targetN.boundingHeight = value.y;
- }
- else {
- cc.error('The new boundingBox must be Vec2');
- }
- },
- type: cc.Vec2
- },
-
- lineHeight: {
- get: function() {
- return this.targetN.getLineHeight();
- },
- set: function (value) {
- if (typeof value === 'number') {
- this.targetN.setLineHeight( value );
- this.targetN._setUpdateTextureDirty();
- }
- else {
- cc.error('The new lineHeight must be number');
- }
- }
- },
-
-
- _text: {
- default: 'Label'
- },
-
- _fontSize: {
- default: 16
- },
-
- _fontFamily: {
- default: null
- },
-
- _align: {
- default: cc.TextAlignment.LEFT
- },
-
- _verticalAlign: {
- default: cc.VerticalTextAlignment.TOP
- },
-
- _boundingBox: {
- default: null
- },
-
- _lineHeight: {
- default: null
- }
- },
-
- onBeforeSerialize: function () {
- NodeWrapper.prototype.onBeforeSerialize.call(this);
-
- this._text = this.text;
- this._fontSize = this.fontSize;
- this._fontFamily = this.fontFamily;
- this._align = this.align;
- this._verticalAlign = this.verticalAlign;
- this._boundingBox = [this.boundingBox.x, this.boundingBox.y];
- this._lineHeight = this.lineHeight;
- },
-
- createNode: function (node) {
-
- node = node || new cc.LabelTTF();
-
- NodeWrapper.prototype.createNode.call(this, node);
-
- node.string = this._text;
- node.fontSize = this._fontSize;
- node.fontName = this._fontFamily === null ? node.fontName : this._fontFamily;
- node.textAlign = this._align;
- node.verticalAlign = this._verticalAlign;
-
- if (typeof this._lineHeight === 'number' &&
- node.setLineHeight) {
- node.setLineHeight( this._lineHeight );
- }
-
- var boundingBox = this._boundingBox;
- if (boundingBox) {
- node.boundingWidth = boundingBox[0];
- node.boundingHeight = boundingBox[1];
- }
-
- Utils.setFontToNode(this.font, node);
-
- return node;
- }
-});
-
-cc.LabelTTFWrapper = module.exports = LabelTTFWrapper;
diff --git a/cocos2d/ToMerge/wrappers/ui/button.js b/cocos2d/ToMerge/wrappers/ui/button.js
deleted file mode 100644
index aeb5b9f2c6..0000000000
--- a/cocos2d/ToMerge/wrappers/ui/button.js
+++ /dev/null
@@ -1,182 +0,0 @@
-var Utils = require('../utils');
-
-var Scale9Wrapper = require('./scale9');
-
-var ButtonWrapper = cc.Class({
- name: 'cc.ButtonWrapper',
- extends: Scale9Wrapper,
-
- properties: {
- normalTexture: {
- get: function () {
- return this._normalTexture;
- },
- set: function ( value ) {
- this._normalTexture = value;
- this.targetN.loadTextureNormal( value );
- },
- url: cc.Texture2D
- },
-
- pressedTexture: {
- get: function () {
- return this._pressedTexture;
- },
- set: function ( value ) {
- this._pressedTexture = value;
- this.targetN.loadTexturePressed( value );
- },
- url: cc.Texture2D
- },
-
- disabledTexture: {
- get: function () {
- return this._disabledTexture;
- },
- set: function ( value ) {
- this._disabledTexture = value;
- this.targetN.loadTextureDisabled( value );
- },
- url: cc.Texture2D
- },
-
- text: {
- get: function () {
- return this.targetN.titleText;
- },
- set: function (value) {
- if (typeof value === 'string') {
- this.targetN.titleText = value;
- }
- else {
- cc.error('The new text must be String');
- }
- }
- },
-
- fontSize: {
- get: function () {
- return this.targetN.titleFontSize;
- },
- set: function (value) {
- if ( !isNaN(value) ) {
- this.targetN.titleFontSize = value;
- }
- else {
- cc.error('The new fontSize must not be NaN');
- }
- }
- },
-
- _font: {
- default: null,
- type: cc.TTFFont,
- visible: true,
-
- notify: function () {
- var value = this._font;
- if (!value || value instanceof cc.TTFFont) {
- Utils.setFontToNode(value, this.targetN);
- }
- else {
- cc.error('The new font must be cc.TTFFont');
- }
- }
- },
-
- fontFamily: {
- get: function () {
- return this.targetN.titleFontName;
- },
- set: function (value) {
- if (typeof value === 'string') {
- this.targetN.titleFontName = value;
- }
- else {
- cc.error('The new fontFamily must be String');
- }
- }
- },
-
- fontColor: {
- get: function () {
- var color = this.targetN.titleColor;
- return color || cc.Color.WHITE;
- },
- set: function (value) {
- if (value instanceof cc.Color) {
- this.targetN.titleColor = value;
- }
- else {
- cc.error('The new fontColor must be cc.Color');
- }
- },
- },
-
- _text: {
- default: 'Button'
- },
-
- _fontSize: {
- default: 16
- },
-
- _fontFamily: {
- default: null
- },
-
- _fontColor: {
- default: null
- },
-
- _normalTexture: {
- default: '',
- url: cc.Texture2D
- },
-
- _pressedTexture: {
- default: '',
- url: cc.Texture2D
- },
-
- _disabledTexture: {
- default: '',
- url: cc.Texture2D
- }
- },
-
- onBeforeSerialize: function () {
- Scale9Wrapper.prototype.onBeforeSerialize.call(this);
-
- this._text = this.text;
- this._fontSize = this.fontSize;
- this._fontFamily = this.fontFamily;
-
- var color = this.fontColor;
- this._fontColor = [color.r, color.g, color.b, color.a];
- },
-
- createNode: function (node) {
-
- node = node || new ccui.Button();
- node.loadTextures(this._normalTexture, this._pressedTexture, this._disabledTexture);
-
- node.titleText = this._text;
- node.titleFontSize = this._fontSize;
- node.titleFontName = this._fontFamily === null ? node.titleFontName : this._fontFamily;
-
- Utils.setFontToNode(this._font, node);
-
- var color = this._fontColor;
- if (color) {
- color = new cc.Color(this._fontColor[0], this._fontColor[1], this._fontColor[2], this._fontColor[3]);
- node.titleColor = color;
- }
-
- Scale9Wrapper.prototype.createNode.call(this, node);
-
- return node;
- }
-});
-
-cc.ButtonWrapper = module.exports = ButtonWrapper;
diff --git a/cocos2d/ToMerge/wrappers/ui/loading-bar.js b/cocos2d/ToMerge/wrappers/ui/loading-bar.js
deleted file mode 100644
index 2b3293278d..0000000000
--- a/cocos2d/ToMerge/wrappers/ui/loading-bar.js
+++ /dev/null
@@ -1,85 +0,0 @@
-
-var Scale9Wrapper = require('./scale9');
-
-var LoadingBarWrapper = cc.Class({
- name: 'cc.LoadingBarWrapper',
- extends: Scale9Wrapper,
-
- properties: {
- texture_: {
- get: function () {
- return this.texture;
- },
- set: function (value) {
- this.texture = value;
- this.targetN.loadTexture( value );
- },
- url: cc.Texture2D,
- displayName: 'Texture'
- },
-
- direction: {
- get: function () {
- return this.targetN.direction;
- },
- set: function (value) {
- if ( typeof value === 'number' && !isNaN(value) ) {
- this.targetN.direction = value;
- }
- else {
- cc.error('The new direction must be number');
- }
- },
-
- type: ccui.LoadingBar.Type
- },
-
- percent: {
- get: function () {
- return this.targetN.percent;
- },
- set: function (value) {
- if ( typeof value === 'number' && !isNaN(value) ) {
- this.targetN.percent = value;
- }
- else {
- cc.error('The new percent must be number');
- }
- }
- },
-
- _direction: {
- default: ccui.LoadingBar.Type.LEFT
- },
-
- _percent: {
- default: 100
- },
-
- texture: {
- default: '',
- url: cc.Texture2D,
- visible: false
- }
- },
-
- onBeforeSerialize: function () {
- Scale9Wrapper.prototype.onBeforeSerialize.call(this);
-
- this._direction = this.direction;
- this._percent = this.percent;
- },
-
- createNode: function (node) {
- node = node || new ccui.LoadingBar();
- node.loadTexture(this.texture);
- node.percent = this._percent;
- node.direction = this._direction;
-
- Scale9Wrapper.prototype.createNode.call(this, node);
-
- return node;
- }
-});
-
-cc.LoadingBarWrapper = module.exports = LoadingBarWrapper;
diff --git a/cocos2d/ToMerge/wrappers/ui/page-view.js b/cocos2d/ToMerge/wrappers/ui/page-view.js
deleted file mode 100644
index 0e7dfe5d87..0000000000
--- a/cocos2d/ToMerge/wrappers/ui/page-view.js
+++ /dev/null
@@ -1,44 +0,0 @@
-
-var LayoutWrapper = require('./layout');
-
-var PageViewWrapper = cc.Class({
- name: 'cc.PageViewWrapper',
- extends: LayoutWrapper,
-
- onChildSiblingIndexChanged: function () {
- var pages = this.targetN._pages;
- pages.sort(function (a, b) {
- return a.getOrderOfArrival() > b.getOrderOfArrival() ? 1 : -1;
- });
-
- LayoutWrapper.prototype.onChildSiblingIndexChanged.call(this);
- },
-
- addChildN: function (child) {
- if (child instanceof ccui.Layout) {
- this.targetN.addPage(child);
- }
- else {
- this.targetN.addChild(child);
- }
- },
-
- removeChildN: function (child) {
- if (child instanceof ccui.Layout) {
- this.targetN.removePage(child);
- }
- else {
- this.targetN.removeChild(child);
- }
- },
-
- createNode: function (node) {
- node = node || new ccui.PageView();
-
- LayoutWrapper.prototype.createNode.call(this, node);
-
- return node;
- }
-});
-
-cc.PageViewWrapper = module.exports = PageViewWrapper;
diff --git a/cocos2d/ToMerge/wrappers/ui/scale9-sprite.js b/cocos2d/ToMerge/wrappers/ui/scale9-sprite.js
deleted file mode 100644
index b412c00a01..0000000000
--- a/cocos2d/ToMerge/wrappers/ui/scale9-sprite.js
+++ /dev/null
@@ -1,58 +0,0 @@
-
-var Scale9Wrapper = require('./scale9');
-
-var Scale9SpriteWrapper = cc.Class({
- name: 'cc.Scale9SpriteWrapper',
- extends: Scale9Wrapper,
-
- properties: {
-
- childrenN: {
- get: function () {
- var renderer = this.targetN.getVirtualRenderer();
- var children = this.targetN.children.filter( function (child) {
- return child !== renderer;
- });
- return children;
- },
- },
-
- texture_: {
- get: function () {
- return this.texture;
- },
- set: function (value) {
- this.texture = value;
- this.targetN.loadTexture( value );
- },
- url: cc.Texture2D
- },
-
- texture: {
- default: '',
- url: cc.Texture2D,
- visible: false
- }
- },
-
- createNode: function (node) {
- node = node || new ccui.ImageView(this.texture);
-
- Scale9Wrapper.prototype.createNode.call(this, node);
-
- return node;
- }
-});
-
-// ccui.ImageView not implement getRotation
-// we implement here
-if (!cc.sys.isNative) {
- var _p = ccui.ImageView.prototype;
- _p.getRotation = function() {
- return this._imageRenderer.getRotation();
- };
-
- cc.js.getset(_p, 'rotation', _p.getRotation, _p.setRotation);
-}
-
-cc.Scale9SpriteWrapper = module.exports = Scale9SpriteWrapper;
diff --git a/cocos2d/ToMerge/wrappers/ui/scale9.js b/cocos2d/ToMerge/wrappers/ui/scale9.js
deleted file mode 100644
index aee1ca6f30..0000000000
--- a/cocos2d/ToMerge/wrappers/ui/scale9.js
+++ /dev/null
@@ -1,171 +0,0 @@
-
-var WidgetWrapper = require('./widget');
-
-var Scale9Wrapper = cc.Class({
- name: 'cc.Scale9Wrapper',
- extends: WidgetWrapper,
-
- ctor: function () {
- this._scale9Size = null;
- this._updatingCapInsets = false;
- },
-
- properties: {
- enableScale9: {
- get: function () {
- return this.targetN.isScale9Enabled();
- },
- set: function (value) {
- if (typeof value === 'boolean') {
- if (!value) this._scale9Size = this.size;
-
- this.targetN.setScale9Enabled( value );
-
- if (value && this._scale9Size) this.size = this._scale9Size;
- }
- else {
- cc.error('The new enableScale9 must be boolean');
- }
- }
- },
-
- left: {
- default: 0,
- range: [0, Number.MAX_SAFE_INTEGER],
-
- notify: function () {
- this._updateCapInsets('left');
- }
- },
-
- right: {
- default: 0,
- range: [0, Number.MAX_SAFE_INTEGER],
-
- notify: function () {
- this._updateCapInsets('right');
- }
- },
-
- top: {
- default: 0,
- range: [0, Number.MAX_SAFE_INTEGER],
-
- notify: function () {
- this._updateCapInsets('top');
- }
- },
-
- bottom: {
- default: 0,
- range: [0, Number.MAX_SAFE_INTEGER],
-
- notify: function () {
- this._updateCapInsets('bottom');
- }
- },
-
- _enableScale9: {
- default: false
- },
-
- _capInsets: {
- default: null
- }
- },
-
- getVirtualRendererSize: function () {
- var renderer = this.targetN.getVirtualRenderer();
- return renderer ? renderer._spriteRect : cc.size(0,0);
- },
-
- _updateCapInsets: function (type) {
- if (!this.targetN || this._updatingCapInsets) return;
- this._updatingCapInsets = true;
-
- var size = this.getVirtualRendererSize();
-
- var w = size.width - this.left - this.right;
- var h = size.height - this.top - this.bottom;
-
- // width and height should be greater than 0
- if (type === 'left') {
- if (this.left > size.width-1) {
- this.left = size.width-1;
- this.right = 0;
- w = 1;
- }
- else if (w <= 0) {
- this.right += w;
- w = 1;
- }
- }
- else if (type === 'right') {
- if (this.right > size.width-1) {
- this.right = size.width-1;
- this.left = 0;
- w = 1;
- }
- else if (w <= 0) {
- this.left += w;
- w = 1;
- }
- }
- else if (type === 'top') {
- if (this.top > size.height-1) {
- this.top = size.height-1;
- this.bottom = 0;
- h = 1;
- }
- else if (h <= 0) {
- this.bottom += h;
- h = 1;
- }
- }
- else if (type === 'bottom') {
- if (this.bottom > size.height-1) {
- this.bottom = size.height-1;
- this.top = 0;
- h = 1;
- }
- else if (h <= 0) {
- this.top += h;
- h = 1;
- }
- }
-
- var x = this.left;
- var y = this.top;
-
- this.targetN.setCapInsets( cc.rect(x, y, w, h) );
- this._capInsets = [x, y, w, h];
-
- this._updatingCapInsets = false;
- },
-
- onBeforeSerialize: function () {
- WidgetWrapper.prototype.onBeforeSerialize.call(this);
-
- this._enableScale9 = this.enableScale9;
- },
-
- createNode: function (node) {
- if (!node) {
- cc.error('Can\'t create a node from Scale9Wrapper');
- return;
- }
-
- node.setScale9Enabled( this._enableScale9 );
-
- var capInsets = this._capInsets;
- if ( capInsets && this._enableScale9 ) {
- node.setCapInsets( cc.rect(capInsets[0], capInsets[1], capInsets[2], capInsets[3]) );
- }
-
- WidgetWrapper.prototype.createNode.call(this, node);
-
- return node;
- }
-});
-
-module.exports = Scale9Wrapper;
diff --git a/cocos2d/ToMerge/wrappers/ui/slider.js b/cocos2d/ToMerge/wrappers/ui/slider.js
deleted file mode 100644
index 48a25d9fc0..0000000000
--- a/cocos2d/ToMerge/wrappers/ui/slider.js
+++ /dev/null
@@ -1,139 +0,0 @@
-
-var Scale9Wrapper = require('./scale9');
-
-var SliderWrapper = cc.Class({
- name: 'cc.SliderWrapper',
- extends: Scale9Wrapper,
-
- properties: {
- bgBar_: {
- get: function () {
- return this.bgBar;
- },
- set: function (value) {
- this.bgBar = value;
- this.targetN.loadBarTexture( value );
- },
- url: cc.Texture2D,
- displayName: 'Bg Bar'
- },
-
- fgBar_: {
- get: function () {
- return this.fgBar;
- },
- set: function (value) {
- this.fgBar = value;
- this.targetN.loadProgressBarTexture( value );
- },
- url: cc.Texture2D,
- displayName: 'Fg Bar'
- },
-
- control_: {
- get: function () {
- return this.control;
- },
- set: function (value) {
- this.control = value;
- this.targetN.loadSlidBallTextureNormal( value );
- },
- url: cc.Texture2D,
- displayName: 'Control'
- },
-
- controlPressed_: {
- get: function () {
- return this.controlPressed;
- },
- set: function (value) {
- this.controlPressed = value;
- this.targetN.loadSlidBallTexturePressed( value );
- },
- url: cc.Texture2D,
- displayName: 'Control Pressed'
- },
-
- controlDisabled_: {
- get: function () {
- return this.controlDisabled;
- },
- set: function (value) {
- this.controlDisabled = value;
- this.targetN.loadSlidBallTextureDisabled( value );
- },
- url: cc.Texture2D,
- displayName: 'Control Disabled'
- },
-
- percent: {
- get: function () {
- return this.targetN.percent;
- },
- set: function (value) {
- if ( typeof value === 'number' && !isNaN(value) ) {
- this.targetN.percent = value;
- }
- else {
- cc.error('The new percent must be number');
- }
- }
- },
-
- _percent: {
- default: 0
- },
-
- bgBar: {
- default: '',
- url: cc.Texture2D,
- visible: false
- },
-
- fgBar: {
- default: '',
- url: cc.Texture2D,
- visible: false
- },
-
- control: {
- default: '',
- url: cc.Texture2D,
- visible: false
- },
-
- controlPressed: {
- default: '',
- url: cc.Texture2D,
- visible: false
- },
-
- controlDisabled: {
- default: '',
- url: cc.Texture2D,
- visible: false
- },
- },
-
- onBeforeSerialize: function () {
- Scale9Wrapper.prototype.onBeforeSerialize.call(this);
-
- this._percent = this.percent;
- },
-
- createNode: function (node) {
- node = node || new ccui.Slider();
-
- node.loadBarTexture( this.bgBar );
- node.loadProgressBarTexture( this.fgBar );
- node.loadSlidBallTextures( this.control, this.controlPressed, this.controlDisabled );
-
- node.percent = this._percent;
-
- Scale9Wrapper.prototype.createNode.call(this, node);
-
- return node;
- }
-});
-
-cc.SliderWrapper = module.exports = SliderWrapper;
diff --git a/cocos2d/ToMerge/wrappers/ui/text-bitmap-font.js b/cocos2d/ToMerge/wrappers/ui/text-bitmap-font.js
deleted file mode 100644
index 937003c913..0000000000
--- a/cocos2d/ToMerge/wrappers/ui/text-bitmap-font.js
+++ /dev/null
@@ -1,70 +0,0 @@
-
-var WidgetWrapper = require('./widget');
-
-var TextBMFontWrapper = cc.Class({
- name: 'cc.TextBMFontWrapper',
- extends: WidgetWrapper,
-
- properties: {
- text: {
- get: function () {
- return this.targetN.string;
- },
- set: function (value) {
- if (typeof value === 'string') {
- this.targetN.string = value;
- }
- else {
- cc.error('The new text must be String');
- }
- }
- },
-
- bitmapFont_: {
- get: function () {
- return this.targetN._file || '';
- },
- set: function (value) {
- cc.loader.load(value, function () {
- this.targetN.setFntFile(value);
- }.bind(this) );
- },
- url: cc.BitmapFont
- },
-
- _text: {
- default: 'TextBMFont'
- },
-
- bitmapFont: {
- default: '',
- url: cc.BitmapFont,
- visible: false
- }
- },
-
- onBeforeSerialize: function () {
- WidgetWrapper.prototype.onBeforeSerialize.call(this);
-
- this._text = this.text;
- this.bitmapFont = this.bitmapFont_;
- },
-
- createNode: function (node) {
- node = node || new ccui.TextBMFont();
- node.string = this._text;
- node.setFntFile(this.bitmapFont);
-
- WidgetWrapper.prototype.createNode.call(this, node);
-
- return node;
- }
-});
-
-var originSetFntFile = ccui.TextBMFont.prototype.setFntFile;
-ccui.TextBMFont.prototype.setFntFile = function (value) {
- this._file = value;
- originSetFntFile.call(this, value);
-};
-
-cc.TextBMFontWrapper = module.exports = TextBMFontWrapper;
diff --git a/cocos2d/ToMerge/wrappers/ui/text.js b/cocos2d/ToMerge/wrappers/ui/text.js
deleted file mode 100644
index ecc99cf366..0000000000
--- a/cocos2d/ToMerge/wrappers/ui/text.js
+++ /dev/null
@@ -1,178 +0,0 @@
-var Utils = require('../utils');
-
-var WidgetWrapper = require('./widget');
-
-var TextWrapper = cc.Class({
- name: 'cc.TextWrapper',
- extends: WidgetWrapper,
-
- ctor: function () {
- this._boundingBox = [100, 100]
- },
-
- properties: {
- text: {
- get: function () {
- return this.targetN.string;
- },
- set: function (value) {
- if (typeof value === 'string') {
- this.targetN.string = value;
- }
- else {
- cc.error('The new text must be String');
- }
- }
- },
-
- fontSize: {
- get: function () {
- return this.targetN.fontSize;
- },
- set: function (value) {
- if ( !isNaN(value) ) {
- this.targetN.fontSize = value;
- }
- else {
- cc.error('The new fontSize must not be NaN');
- }
- }
- },
-
- font: {
- default: null,
- type: cc.TTFFont,
-
- notify: function () {
- if ( !this.targetN ) return;
-
- var value = this.font;
- if (!value || value instanceof cc.TTFFont) {
- Utils.setFontToNode(value, this.targetN);
- }
- else {
- cc.error('The new font must be cc.TTFFont');
- }
- }
- },
-
- fontFamily: {
- get: function () {
- return this.targetN.fontName;
- },
- set: function (value) {
- if (typeof value === 'string') {
- this.targetN.fontName = value;
- }
- else {
- cc.error('The new fontFamily must be String');
- }
- }
- },
-
- align: {
- get: function () {
- return this.targetN.getTextHorizontalAlignment();
- },
- set: function ( value ) {
- if (typeof value === 'number') {
- this.targetN.textAlign = value;
- }
- else {
- cc.error('The new textAlign must be number');
- }
- },
- type: cc.TextAlignment
- },
-
- verticalAlign: {
- get: function () {
- return this.targetN.getTextVerticalAlignment();
- },
- set: function ( value ) {
- if (typeof value === 'number') {
- this.targetN.verticalAlign = value;
- }
- else {
- cc.error('The new verticalAlign must be number');
- }
- },
- type: cc.VerticalTextAlignment
- },
-
- boundingBox: {
- get: function () {
- var size = this.targetN.getTextAreaSize();
- return new cc.Vec2(size.width, size.height);
- },
- set: function (value) {
- if (value instanceof cc.Vec2) {
- this.targetN.setTextAreaSize( cc.size( value.x, value.y ) );
- }
- else {
- cc.error('The new boundingBox must be Vec2');
- }
- },
- type: cc.Vec2
- },
-
- _text: {
- default: 'Label'
- },
-
- _fontSize: {
- default: 16
- },
-
- _fontFamily: {
- default: null
- },
-
- _align: {
- default: cc.TextAlignment.CENTER
- },
-
- _verticalAlign: {
- default: cc.VerticalTextAlignment.CENTER
- },
-
- _boundingBox: {
- default: null
- }
- },
-
- onBeforeSerialize: function () {
- WidgetWrapper.prototype.onBeforeSerialize.call(this);
-
- this._text = this.text;
- this._fontSize = this.fontSize;
- this._fontFamily = this.fontFamily;
- this._align = this.align;
- this._verticalAlign = this.verticalAlign;
- this._boundingBox = [this.boundingBox.x, this.boundingBox.y];
- },
-
- createNode: function (node) {
- node = node || new ccui.Text();
- node.ignoreContentAdaptWithSize(false);
-
- WidgetWrapper.prototype.createNode.call(this, node);
-
- node.string = this._text;
- node.fontSize = this._fontSize;
- node.fontName = this._fontFamily === null ? node.fontName : this._fontFamily;
- node.textAlign = this._align;
- node.verticalAlign = this._verticalAlign;
-
- var boundingBox = this._boundingBox;
- if (boundingBox) {
- node.setTextAreaSize( cc.size( boundingBox[0], boundingBox[1] ) );
- }
-
- Utils.setFontToNode(this.font, node);
-
- return node;
- }
-});
-
-cc.TextWrapper = module.exports = TextWrapper;
diff --git a/cocos2d/ToMerge/wrappers/ui/widget.js b/cocos2d/ToMerge/wrappers/ui/widget.js
deleted file mode 100644
index b589945010..0000000000
--- a/cocos2d/ToMerge/wrappers/ui/widget.js
+++ /dev/null
@@ -1,245 +0,0 @@
-
-var NodeWrapper = require('../node');
-
-var desc = Object.getOwnPropertyDescriptor(NodeWrapper.prototype, 'parentN');
-
-var WidgetWrapper = cc.Class({
- name: 'cc.WidgetWrapper',
- extends: NodeWrapper,
-
- ctor: function () {
- this._ignoreUpdateLayoutParameter = false;
- },
-
- properties: {
-
- position: {
- get: function () {
- return new cc.Vec2(this.targetN.x, this.targetN.y);
- },
- set: function (value) {
- if ( value instanceof cc.Vec2 ) {
- this.targetN.setPosition(value.x, value.y);
-
- if (this.canDoAnchor) {
- this.updateAnchorPositon();
- }
- }
- else {
- cc.error('The new position must be cc.Vec2');
- }
- }
- },
-
- parentN: {
- get: function () {
- var parent = this.targetN.parent;
-
- if (parent) {
- var ancient = parent.parent;
- if ( ancient && ancient instanceof ccui.ScrollView) {
- return ancient;
- }
- }
-
- return parent;
- },
- set: desc.set
- },
-
- enabled: {
- get: function () {
- return this.targetN.enabled;
- },
- set: function (value) {
- if (typeof value === 'boolean') {
- this.targetN.enabled = value;
- this.targetN.bright = value;
- }
- else {
- cc.error('The new enabled must be boolean');
- }
- }
- },
-
- touchEnabled: {
- get: function () {
- return this.targetN.touchEnabled;
- },
- set: function (value) {
- if (typeof value === 'boolean') {
- this.targetN.touchEnabled = value;
- }
- else {
- cc.error('The new touchEnabled must be boolean');
- }
- }
- },
-
- canDoAnchor: {
- get: function () {
- var parentN = this.parentN;
- return parentN && parentN instanceof ccui.Layout;
- }
- },
-
- anchorAlign: {
- default: ccui.RelativeLayoutParameter.Type.PARENT_TOP_LEFT,
- type: ccui.RelativeLayoutParameter.Type,
-
- notify: function () {
- this.updateAnchorPositon();
- }
- },
-
- widgetLayoutType: {
- default: ccui.Layout.Type.RELATIVE,
- type: ccui.Layout.Type,
-
- notify: function (oldValue) {
- if (oldValue === this.widgetLayoutType) return;
-
- this._ignoreUpdateLayoutParameter = true;
- this.anchorLeft = this.anchorTop = this.anchorRight = this.anchorBottom = 0;
- this._ignoreUpdateLayoutParameter = false;
-
- this.updateLayoutParameter();
- }
- },
-
- anchorLeft: {
- default: 0,
-
- notify: function () {
- this.updateLayoutParameter();
- }
- },
-
- anchorRight: {
- default: 0,
-
- notify: function () {
- this.updateLayoutParameter();
- }
- },
-
- anchorTop: {
- default: 0,
-
- notify: function () {
- this.updateLayoutParameter();
- }
- },
-
- anchorBottom: {
- default: 0,
-
- notify: function () {
- this.updateLayoutParameter();
- }
- },
-
- _enabled: {
- default: null
- },
-
- _touchEnabled: {
- default: null
- },
- },
-
- updateLayoutParameter: function (node) {
- if (this._ignoreUpdateLayoutParameter) return;
-
- node = node || this.targetN;
-
- var parameter;
-
- if (this.widgetLayoutType === ccui.Layout.Type.RELATIVE) {
- parameter = new ccui.RelativeLayoutParameter();
- parameter.setAlign(this.anchorAlign);
- }
- else {
- parameter = new ccui.LinearLayoutParameter();
- }
- parameter.setMargin(this.anchorLeft, this.anchorTop, this.anchorRight, this.anchorBottom);
-
- node.setLayoutParameter(parameter);
-
- if (this.targetN) {
- this.doParentLayout();
- }
- },
-
- updateAnchorPositon: function () {
- this._ignoreUpdateLayoutParameter = true;
-
- var targetN = this.targetN;
- var cs = targetN.getContentSize();
- var ap = targetN.getAnchorPointInPoints();
- var ls = targetN.parent._getLayoutContentSize();
-
- this.anchorLeft = targetN.x - ap.x;
- this.anchorRight = ls.width - targetN.x - (cs.width - ap.x);
- this.anchorTop = ls.height - targetN.y - (cs.height - ap.y);
- this.anchorBottom = targetN.y - ap.y;
-
- this._ignoreUpdateLayoutParameter = false;
- this.updateLayoutParameter();
- },
-
- onSizeChanged: function () {
- this.doParentLayout();
- },
-
- _getUrlFromRenderer: function (renderer) {
- if (!renderer) return '';
-
- var texture;
- if ( renderer.texture ) texture = renderer.texture;
- if ( renderer._scale9Image ) texture = renderer._scale9Image.texture;
-
- return texture ? texture.url : '';
- },
-
- doParentLayout: function () {
- var parent = this.parent;
- while (parent) {
- if (parent instanceof cc.LayoutWrapper) {
- parent.doLayout();
- return;
- }
- parent = parent.parent;
- }
- },
-
- onBeforeSerialize: function () {
- NodeWrapper.prototype.onBeforeSerialize.call(this);
-
- this._enabled = this.enabled;
- this._touchEnabled = this.touchEnabled;
- },
-
- createNode: function (node) {
- if (!node) {
- cc.error('Can\'t create a node from WidgetWrapper');
- return;
- }
-
- NodeWrapper.prototype.createNode.call(this, node);
-
- this.updateLayoutParameter(node);
-
- if (this._enabled !== null) {
- node.enabled = this._enabled;
- node.bright = this._enabled;
- }
-
- if (this._touchEnabled !== null)
- node.setTouchEnabled( this._touchEnabled );
-
- return node;
- }
-});
-
-module.exports = WidgetWrapper;
diff --git a/cocos2d/animation/animation-animator.js b/cocos2d/animation/animation-animator.js
index 949bef9044..a23a35caa6 100644
--- a/cocos2d/animation/animation-animator.js
+++ b/cocos2d/animation/animation-animator.js
@@ -60,13 +60,40 @@ p.resumeState = function (state) {
if (state) {
state.resume();
}
+
+ if (this.isPaused) {
+ this.resume();
+ }
};
p.setStateTime = function (state, time) {
if (state) {
state.setTime(time);
}
-}
+};
+
+p.onStop = function () {
+ var anims = this.playingAnims;
+ for (var i = 0, l = anims.length; i < l; i++) {
+ anims[i].stop();
+ }
+
+ Animator.prototype.onStop.call(this);
+};
+
+p.onPause = function () {
+ var anims = this.playingAnims;
+ for (var i = 0, l = anims.length; i < l; i++) {
+ anims[i].pause();
+ }
+};
+
+p.onResume = function () {
+ var anims = this.playingAnims;
+ for (var i = 0, l = anims.length; i < l; i++) {
+ anims[i].resume();
+ }
+};
if (CC_DEV) {
p.reloadClip = function (state) {
diff --git a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js
index a066168d2e..5871c08568 100644
--- a/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js
+++ b/cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js
@@ -86,8 +86,10 @@
if (this._clipElemType) {
var locCache = cc.ClippingNode.CanvasRenderCmd._getSharedCache();
var canvas = context.canvas;
- locCache.width = canvas.width;
- locCache.height = canvas.height; //note: on some browser, it can't clear the canvas, e.g. baidu
+ if (locCache.width !== canvas.width)
+ locCache.width = canvas.width;
+ if (locCache.height !== canvas.height)
+ locCache.height = canvas.height; //note: on some browser, it can't clear the canvas, e.g. baidu
var locCacheCtx = locCache.getContext("2d");
locCacheCtx.drawImage(canvas, 0, 0); //save the result to shareCache canvas
} else {
diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js
index c92f763bad..a62284d395 100644
--- a/cocos2d/core/CCDirector.js
+++ b/cocos2d/core/CCDirector.js
@@ -90,8 +90,7 @@ cc.Director = Class.extend(/** @lends cc.Director# */{
_projectionDelegate: null,
_loadingScene: '',
- // The root of rendering scene graph
- _runningScene: null,
+ _runningScene: null, // The root of rendering scene graph
// The entity-component scene
_scene: null,
@@ -473,6 +472,16 @@ cc.Director = Class.extend(/** @lends cc.Director# */{
runScene: function (scene, onBeforeLoadScene) {
cc.assert(scene, cc._LogInfos.Director.pushScene);
+ // detach persist nodes
+ var i, node, game = cc.game;
+ var persistNodes = game._persistRootNodes;
+ for (i = persistNodes.length - 1; i >= 0; --i) {
+ node = persistNodes[i];
+ game._ignoreRemovePersistNode = node;
+ node.parent = null;
+ game._ignoreRemovePersistNode = null;
+ }
+
// unload scene
var oldScene = this._scene;
if (cc.isValid(oldScene)) {
@@ -488,13 +497,6 @@ cc.Director = Class.extend(/** @lends cc.Director# */{
}
this.emit(cc.Director.EVENT_BEFORE_SCENE_LAUNCH, scene);
- // Re-add persist node root
- var persistNodes = cc.game._persistRootNodes;
- for (var i = 0; i < persistNodes.length; ++i) {
- var node = persistNodes[i];
- node.parent = scene;
- }
-
var sgScene = scene;
// Run an Entity Scene
@@ -504,6 +506,12 @@ cc.Director = Class.extend(/** @lends cc.Director# */{
this._scene = scene;
sgScene = scene._sgNode;
+
+ // Re-attach persist nodes
+ for (i = 0; i < persistNodes.length; ++i) {
+ node = persistNodes[i];
+ node.parent = scene;
+ }
}
// Run or replace rendering scene
diff --git a/cocos2d/core/CCGame.js b/cocos2d/core/CCGame.js
index 34137f8875..2e9ebbce04 100644
--- a/cocos2d/core/CCGame.js
+++ b/cocos2d/core/CCGame.js
@@ -19,6 +19,7 @@ var game = /** @lends cc.game# */{
_eventShow: null,
_persistRootNodes: [],
+ _ignoreRemovePersistNode: null,
/**
* Key of config
@@ -282,7 +283,7 @@ var game = /** @lends cc.game# */{
* @param {Node} node - The node to be made persistent
*/
addPersistRootNode: function (node) {
- if (!node instanceof cc.Node)
+ if (!(node instanceof cc.Node))
return;
var index = this._persistRootNodes.indexOf(node);
if (index === -1) {
@@ -291,10 +292,14 @@ var game = /** @lends cc.game# */{
if (!node.parent) {
node.parent = scene;
}
- else if (node.parent !== scene) {
+ else if ( !(node.parent instanceof cc.Scene) ) {
cc.warn('The node can not be made persist because it\'s not under root node.');
return;
}
+ else if (node.parent !== scene) {
+ cc.warn('The node can not be made persist because it\'s not in current scene.');
+ return;
+ }
this._persistRootNodes.push(node);
node._persistNode = true;
}
@@ -307,11 +312,13 @@ var game = /** @lends cc.game# */{
* @param {Node} node - The node to be removed from persistent node list
*/
removePersistRootNode: function (node) {
- var index = this._persistRootNodes.indexOf(node);
- if (index !== -1) {
- this._persistRootNodes.splice(index, 1);
+ if (node !== this._ignoreRemovePersistNode) {
+ var index = this._persistRootNodes.indexOf(node);
+ if (index !== -1) {
+ this._persistRootNodes.splice(index, 1);
+ }
+ node._persistNode = false;
}
- node._persistNode = false;
},
/**
diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js
index 682d6a8f18..2423373633 100644
--- a/cocos2d/core/CCNode.js
+++ b/cocos2d/core/CCNode.js
@@ -61,6 +61,13 @@ var EventType = cc.Enum({
* @readonly
*/
TOUCH_END: 'touchend',
+ /**
+ * The event type for touch end event, you can use its value directly: 'touchcancel'
+ * @property TOUCH_CANCEL
+ * @type {String}
+ * @readonly
+ */
+ TOUCH_CANCEL: 'touchcancel',
/**
* The event type for mouse down events, you can use its value directly: 'mousedown'
@@ -97,12 +104,20 @@ var EventType = cc.Enum({
* @readonly
*/
MOUSE_UP: 'mouseup',
+ /**
+ * The event type for mouse wheel events, you can use its value directly: 'mousewheel'
+ * @property MOUSE_WHEEL
+ * @type {String}
+ * @readonly
+ */
+ MOUSE_WHEEL: 'mousewheel',
});
var _touchEvents = [
EventType.TOUCH_START,
EventType.TOUCH_MOVE,
EventType.TOUCH_END,
+ EventType.TOUCH_CANCEL,
];
var _mouseEvents = [
EventType.MOUSE_DOWN,
@@ -110,13 +125,14 @@ var _mouseEvents = [
EventType.MOUSE_MOVE,
EventType.MOUSE_LEAVE,
EventType.MOUSE_UP,
+ EventType.MOUSE_WHEEL,
];
var _touchStartHandler = function (touch, event) {
var pos = touch.getLocation();
var node = this.owner;
- if (node._hitTest(pos)) {
+ if (node._hitTest(pos, this)) {
event.type = EventType.TOUCH_START;
event.touch = touch;
event.bubbles = true;
@@ -133,8 +149,15 @@ var _touchMoveHandler = function (touch, event) {
node.dispatchEvent(event);
};
var _touchEndHandler = function (touch, event) {
+ var pos = touch.getLocation();
var node = this.owner;
- event.type = EventType.TOUCH_END;
+
+ if (node._hitTest(pos, this)) {
+ event.type = EventType.TOUCH_END;
+ }
+ else {
+ event.type = EventType.TOUCH_CANCEL;
+ }
event.touch = touch;
event.bubbles = true;
node.dispatchEvent(event);
@@ -144,7 +167,7 @@ var _mouseDownHandler = function (event) {
var pos = event.getLocation();
var node = this.owner;
- if (node._hitTest(pos)) {
+ if (node._hitTest(pos, this)) {
event.type = EventType.MOUSE_DOWN;
node.dispatchEvent(event);
event.stopPropagation();
@@ -153,7 +176,7 @@ var _mouseDownHandler = function (event) {
var _mouseMoveHandler = function (event) {
var pos = event.getLocation();
var node = this.owner;
- if (node._hitTest(pos)) {
+ if (node._hitTest(pos, this)) {
event.stopPropagation();
if (!this._previousIn) {
event.type = EventType.MOUSE_ENTER;
@@ -173,12 +196,40 @@ var _mouseUpHandler = function (event) {
var pos = event.getLocation();
var node = this.owner;
- if (node._hitTest(pos)) {
+ if (node._hitTest(pos, this)) {
event.type = EventType.MOUSE_UP;
node.dispatchEvent(event);
event.stopPropagation();
}
};
+var _mouseWheelHandler = function (event) {
+ var pos = event.getLocation();
+ var node = this.owner;
+
+ if (node._hitTest(pos, this)) {
+ event.type = EventType.MOUSE_WHEEL;
+ node.dispatchEvent(event);
+ event.stopPropagation();
+ }
+};
+
+var _searchMaskParent = function (node) {
+ if (cc.Mask) {
+ var index = 0;
+ var mask = null;
+ for (var curr = node; curr && curr instanceof cc.Node; curr = curr.parent, ++index) {
+ mask = curr.getComponent(cc.Mask);
+ if (mask) {
+ return {
+ index: index,
+ node: curr
+ };
+ }
+ }
+ }
+
+ return null;
+};
/**
@@ -817,6 +868,7 @@ var Node = cc.Class({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches: true,
owner: this,
+ mask: _searchMaskParent(this),
onTouchBegan: _touchStartHandler,
onTouchMoved: _touchMoveHandler,
onTouchEnded: _touchEndHandler
@@ -830,9 +882,11 @@ var Node = cc.Class({
event: cc.EventListener.MOUSE,
_previousIn: false,
owner: this,
+ mask: _searchMaskParent(this),
onMouseDown: _mouseDownHandler,
onMouseMove: _mouseMoveHandler,
- onMouseUp: _mouseUpHandler
+ onMouseUp: _mouseUpHandler,
+ onMouseScroll: _mouseWheelHandler,
});
cc.eventManager.addListener(this._mouseListener, this);
}
@@ -883,7 +937,7 @@ var Node = cc.Class({
}
},
- _hitTest: function (point) {
+ _hitTest: function (point, listener) {
var apx = this._anchorPoint.x,
apy = this._anchorPoint.y,
w = this.width,
@@ -896,7 +950,23 @@ var Node = cc.Class({
bottom = point.y - rect.y,
top = rect.y + rect.height - point.y;
if (left >= 0 && right >= 0 && top >= 0 && bottom >= 0) {
- return true;
+ if (listener && listener.mask) {
+ var mask = listener.mask;
+ var parent = this;
+ for (var i = 0; parent && i < mask.index; ++i, parent = parent.parent) {}
+ // find mask parent, should hit test it
+ if (parent === mask.node) {
+ return parent._hitTest(point);
+ }
+ // mask parent no longer exists
+ else {
+ listener.mask = null;
+ return true;
+ }
+ }
+ else {
+ return true;
+ }
}
else {
return false;
diff --git a/cocos2d/core/CCScene.js b/cocos2d/core/CCScene.js
index 73e68ffaaf..d455ed5c8b 100644
--- a/cocos2d/core/CCScene.js
+++ b/cocos2d/core/CCScene.js
@@ -50,8 +50,6 @@ cc.Scene = cc.Class({
var children = this._children;
var DontDestroy = cc.Object.Flags.DontDestroy;
- this._sgNode.release();
-
for (var i = 0, len = children.length; i < len; ++i) {
var child = children[i];
if (child.isValid) {
diff --git a/cocos2d/core/assets/CCText.js b/cocos2d/core/assets/CCText.js
new file mode 100644
index 0000000000..e3a27b225c
--- /dev/null
+++ b/cocos2d/core/assets/CCText.js
@@ -0,0 +1,12 @@
+/**
+ * Class for text file.
+ * @class TextAsset
+ * @extends Asset
+ * @constructor
+ */
+var TextAsset = cc.Class({
+ name: 'cc.TextAsset',
+ extends: cc.Asset,
+});
+
+cc.TextAsset = TextAsset;
diff --git a/cocos2d/core/base-ui/CCWidgetManager.js b/cocos2d/core/base-ui/CCWidgetManager.js
index f533fd14df..8a9d5ab70c 100644
--- a/cocos2d/core/base-ui/CCWidgetManager.js
+++ b/cocos2d/core/base-ui/CCWidgetManager.js
@@ -144,16 +144,16 @@ var adjustWidgetToAllowMovingInEditor = CC_EDITOR && function (event) {
var deltaInPercent = cc.v2(delta.x / parentSize.width, delta.y / parentSize.height);
if (this.isAlignTop) {
- this.top -= (this.isAbsTop ? delta.y : deltaInPercent.y);
+ this.top -= (this.isAbsoluteTop ? delta.y : deltaInPercent.y);
}
if (this.isAlignBottom) {
- this.bottom += (this.isAbsBottom ? delta.y : deltaInPercent.y);
+ this.bottom += (this.isAbsoluteBottom ? delta.y : deltaInPercent.y);
}
if (this.isAlignLeft) {
- this.left += (this.isAbsLeft ? delta.x : deltaInPercent.x);
+ this.left += (this.isAbsoluteLeft ? delta.x : deltaInPercent.x);
}
if (this.isAlignRight) {
- this.right -= (this.isAbsRight ? delta.x : deltaInPercent.x);
+ this.right -= (this.isAbsoluteRight ? delta.x : deltaInPercent.x);
}
if (this.isAlignHorizontalCenter) {
if (oldPos.x !== newPos.x) {
diff --git a/cocos2d/core/components/CCAnimation.js b/cocos2d/core/components/CCAnimation.js
index f5721a8c60..1dabf77190 100644
--- a/cocos2d/core/components/CCAnimation.js
+++ b/cocos2d/core/components/CCAnimation.js
@@ -106,7 +106,7 @@ var Animation = cc.Class({
set: function (value, force) {
this._currentClip = value;
- if (CC_EDITOR && force) {
+ if (CC_EDITOR && force && value) {
this._updateClip(value);
}
},
diff --git a/cocos2d/core/components/CCButton.js b/cocos2d/core/components/CCButton.js
index 7dfaa5c216..2ea8c1b31f 100644
--- a/cocos2d/core/components/CCButton.js
+++ b/cocos2d/core/components/CCButton.js
@@ -22,8 +22,6 @@
THE SOFTWARE.
****************************************************************************/
-var EventTarget = require("../event/event-target");
-
/**
* Enum for transition type
* @enum Button.Transition
@@ -97,12 +95,6 @@ var ButtonState = {
Disabled: 'disabled'
};
-var EVENT_TOUCH_DOWN = 'touch-down';
-var EVENT_TOUCH_UP = 'touch-up';
-var EVENT_HOVER_IN = 'hover-in';
-var EVENT_HOVER_MOVE = 'hover-move';
-var EVENT_HOVER_OUT = 'hover-out';
-
/**
* Button has 3 Transition types
* When Button state changed:
@@ -123,13 +115,8 @@ var EVENT_HOVER_OUT = 'hover-out';
var Button = cc.Class({
name: 'cc.Button',
extends: require('./CCComponent'),
- mixins: [EventTarget],
ctor: function () {
-
- this._touchListener = null;
- this._mouseListener = null;
-
this._pressed = false;
this._hovered = false;
@@ -138,7 +125,7 @@ var Button = cc.Class({
this._fromColor = null;
this._toColor = null;
this._time = 0;
- this._tarnsitionFinished = true;
+ this._transitionFinished = true;
},
editor: CC_EDITOR && {
@@ -300,7 +287,7 @@ var Button = cc.Class({
},
/**
- * If Button is clicked, will trigger event's handler
+ * If Button is clicked, it will trigger event's handler
* @property {[Button.ClickEvent]} clickEvents
*/
clickEvents: {
@@ -311,32 +298,6 @@ var Button = cc.Class({
},
statics: {
- /**
- * Touch down event
- * @property {String} EVENT_TOUCH_DOWN
- */
- EVENT_TOUCH_DOWN: EVENT_TOUCH_DOWN,
- /**
- * Touch up event
- * @property {String} EVENT_TOUCH_UP
- */
- EVENT_TOUCH_UP: EVENT_TOUCH_UP,
- /**
- * Hover in event
- * @property {String} EVENT_HOVER_IN
- */
- EVENT_HOVER_IN: EVENT_HOVER_IN,
- /**
- * Hover move event
- * @property {String} EVENT_HOVER_MOVE
- */
- EVENT_HOVER_MOVE: EVENT_HOVER_MOVE,
- /**
- * Hover out event
- * @property {String} EVENT_HOVER_OUT
- */
- EVENT_HOVER_OUT: EVENT_HOVER_OUT,
-
Transition: Transition,
ClickEvent: ClickEvent
},
@@ -348,7 +309,6 @@ var Button = cc.Class({
if (!CC_EDITOR) {
this._registerEvent();
- this._registerListeners();
}
},
@@ -357,44 +317,31 @@ var Button = cc.Class({
this._initState();
},
- onDestroy: function () {
- if (this._touchListener) cc.eventManager.removeListener(this._touchListener);
- if (this._mouseListener) cc.eventManager.removeListener(this._mouseListener);
- },
-
update: function (dt) {
var target = this.target;
- if (!this.transition === Transition.COLOR || !target || this._tarnsitionFinished) return;
+ if (!this.transition === Transition.COLOR || !target || this._transitionFinished) return;
this.time += dt;
var ratio = this.time / this.duration;
if (ratio > 1) {
ratio = 1;
- this._tarnsitionFinished = true;
+ this._transitionFinished = true;
}
target.color = this._fromColor.lerp(this._toColor, ratio);
},
_registerEvent: function () {
- this._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(this._touchListener, this.node._sgNode);
+ this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this);
+ this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
+ this.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this);
+ this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancel, this);
- if (!cc.sys.isMobile) {
- this._mouseListener = cc.EventListener.create({
- event: cc.EventListener.MOUSE,
- onMouseMove: this._onMouseMove.bind(this)
- });
- cc.eventManager.addListener(this._mouseListener, this.node._sgNode);
- }
+ this.node.on(cc.Node.EventType.MOUSE_ENTER, this._onMouseMoveIn, this);
+ this.node.on(cc.Node.EventType.MOUSE_LEAVE, this._onMouseMoveOut, this);
},
- _registerListeners: function () {
+ _handleClickEvent: function () {
var events = this.clickEvents;
for (var i = 0, l = events.length; i < l; i++) {
var event = events[i];
@@ -406,11 +353,14 @@ var Button = cc.Class({
var handler = comp[event.handler];
if (!handler) continue;
-
- this.on(EVENT_TOUCH_UP, handler.bind(comp));
+ handler.call(comp)
}
},
+ _cancelButtonClick: function(){
+ this._pressed = false;
+ },
+
_applyTarget: function () {
var target = this.target;
if (target) {
@@ -427,45 +377,63 @@ var Button = cc.Class({
},
// touch event handler
- _onTouchBegan: function (touch) {
+ _onTouchBegan: function (event) {
+ var touch = event.touch;
if (!this.interactable || !this.enabledInHierarchy) return false;
var hit = this._hitTest(touch.getLocation());
if (hit) {
this._pressed = true;
this._applyState(ButtonState.Pressed);
- this.emit(EVENT_TOUCH_DOWN);
}
return hit;
},
+ _onTouchMove: function (event) {
+ var touch = event.touch;
+
+ var hit = this._hitTest(touch.getLocation());
+ if (hit && this._pressed) {
+ this._applyState(ButtonState.Pressed);
+ }else{
+ this._applyState(ButtonState.Normal);
+ }
+ },
+
_onTouchEnded: function () {
if (this._hovered)
+ {
this._applyState(ButtonState.Hover);
- else
- this._applyState(ButtonState.Normal);
+ }
+
+ if(this._pressed){
+ this._applyState(ButtonState.Normal);
+ this._handleClickEvent();
+ }
- this.emit(EVENT_TOUCH_UP);
this._pressed = false;
},
- _onMouseMove: function (event) {
+ _onTouchCancel: function () {
+ this._pressed = false;
+ },
+
+ _onMouseMoveIn: function (event) {
if (this._pressed || !this.interactable || !this.enabledInHierarchy) return;
- var hit = this._hitTest(event.getLocation());
- if (hit) {
- if (!this._hovered) {
- this._hovered = true;
- this._applyState(ButtonState.Hover);
- this.emit(EVENT_HOVER_IN);
- }
- this.emit(EVENT_HOVER_MOVE);
+ if (!this._hovered) {
+ this._hovered = true;
+ this._applyState(ButtonState.Hover);
}
- else if (this._hovered) {
+ },
+
+ _onMouseMoveOut: function(){
+ if (!this.interactable || !this.enabledInHierarchy) return;
+
+ if (this._hovered) {
this._hovered = false;
this._applyState(ButtonState.Normal);
- this.emit(EVENT_HOVER_OUT);
}
},
@@ -489,7 +457,7 @@ var Button = cc.Class({
this._fromColor = target.color.clone();
this._toColor = color;
this.time = 0;
- this._tarnsitionFinished = false;
+ this._transitionFinished = false;
}
}
else if (transition === Transition.SPRITE && this._sprite && sprite) {
diff --git a/cocos2d/core/components/CCComponent.js b/cocos2d/core/components/CCComponent.js
index d9b69e0f48..3ed53be933 100644
--- a/cocos2d/core/components/CCComponent.js
+++ b/cocos2d/core/components/CCComponent.js
@@ -3,6 +3,7 @@ require('../CCNode');
var Flags = cc.Object.Flags;
var IsOnEnableCalled = Flags.IsOnEnableCalled;
+var IsOnLoadStarted = Flags.IsOnLoadStarted;
var IsOnLoadCalled = Flags.IsOnLoadCalled;
var IsOnStartCalled = Flags.IsOnStartCalled;
@@ -199,6 +200,22 @@ var Component = cc.Class({
visible: false
},
+ name: {
+ get: function () {
+ return this._name || this.node.name;
+ //var className = cc.js.getClassName(this);
+ //var index = className.lastIndexOf('.');
+ //if (index >= 0) {
+ // // strip prefix
+ // className = className.slice(index + 1);
+ //}
+ //return this.node.name + '<' + className + '>';
+ },
+ set: function (value) {
+ this._name = value;
+ }
+ },
+
_id: {
default: '',
serializable: false
@@ -299,8 +316,7 @@ var Component = cc.Class({
_isOnLoadCalled: {
get: function () {
return this._objFlags & IsOnLoadCalled;
- },
- visible: false
+ }
},
/**
@@ -388,6 +404,8 @@ var Component = cc.Class({
*/
onLostFocusInEditMode: null,
+ //
+
/**
* Adds a component class to the entity. You can also add component to entity by passing in the name of the
* script.
@@ -499,24 +517,24 @@ var Component = cc.Class({
},
__onNodeActivated: CC_EDITOR ? function (active) {
- if (!(this._objFlags & IsOnLoadCalled) &&
+ if (!(this._objFlags & IsOnLoadStarted) &&
(cc.engine._isPlaying || this.constructor._executeInEditMode)) {
+ this._objFlags |= IsOnLoadStarted;
+
if (this.onLoad) {
callOnLoadInTryCatch(this);
- this._objFlags |= IsOnLoadCalled;
-
- if (!cc.engine._isPlaying) {
- var focused = Editor.Selection.curActivate('node') === this.node.uuid;
- if (focused && this.onFocusInEditMode) {
- callOnFocusInTryCatch(this);
- }
- else if (this.onLostFocusInEditMode) {
- callOnLostFocusInTryCatch(this);
- }
- }
}
- else {
- this._objFlags |= IsOnLoadCalled;
+
+ this._objFlags |= IsOnLoadCalled;
+
+ if (this.onLoad && !cc.engine._isPlaying) {
+ var focused = Editor.Selection.curActivate('node') === this.node.uuid;
+ if (focused && this.onFocusInEditMode) {
+ callOnFocusInTryCatch(this);
+ }
+ else if (this.onLostFocusInEditMode) {
+ callOnLostFocusInTryCatch(this);
+ }
}
Editor._AssetsWatcher.start(this);
}
@@ -525,7 +543,8 @@ var Component = cc.Class({
callOnEnable(this, active);
}
} : function (active) {
- if (!(this._objFlags & IsOnLoadCalled)) {
+ if (!(this._objFlags & IsOnLoadStarted)) {
+ this._objFlags |= IsOnLoadStarted;
if (this.onLoad) {
this.onLoad();
}
@@ -591,27 +610,11 @@ var Component = cc.Class({
cc.assert(callback, cc._LogInfos.Node.schedule);
cc.assert(interval >= 0, cc._LogInfos.Node.schedule_2);
- var key = this.__instanceId;
interval = interval || 0;
repeat = isNaN(repeat) ? cc.REPEAT_FOREVER : repeat;
delay = delay || 0;
- cc.director.getScheduler().schedule(callback, this, interval, repeat, delay, !this.enabledInHierarchy, key);
- },
-
- /**
- *
- * schedules the "update" callback function with a custom priority.
- * This callback function will be called every frame.
- * Scheduled callback functions with a lower priority will be called before the ones that have a higher value.
- * Only one "update" callback function could be scheduled per node (You can't have 2 'update' callback functions).
- *
- * @method scheduleUpdate
- * @param {Number} [priority=0] The priority of the update callback
- */
- scheduleUpdate: function (priority) {
- priority = priority || 0;
- cc.director.getScheduler().scheduleUpdate(this, priority, !this.enabledInHierarchy);
+ cc.director.getScheduler().scheduleCallbackForTarget(this, callback, interval, repeat, delay, !this.enabledInHierarchy);
},
/**
@@ -638,15 +641,6 @@ var Component = cc.Class({
cc.director.getScheduler().unschedule(callback_fn, this);
},
- /**
- * Unschedules the "update" method.
- * @method unscheduleUpdate
- * @see cc.Node#scheduleUpdate
- */
- unscheduleUpdate: function () {
- cc.director.getScheduler().unscheduleUpdate(this);
- },
-
/**
* unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.
* Actions are not affected by this method.
diff --git a/cocos2d/core/components/CCLabel.js b/cocos2d/core/components/CCLabel.js
index 059a3a8fc9..978707b317 100644
--- a/cocos2d/core/components/CCLabel.js
+++ b/cocos2d/core/components/CCLabel.js
@@ -144,7 +144,8 @@ var Label = cc.Class({
notify: function () {
var sgNode = this._sgNode;
if (sgNode) {
- sgNode.setOverflow( this.overflow );
+ //FIXME change this hack if _ccsg.Label.Overflow.NONE is implemented
+ sgNode.setOverflow( (this.overflow === _ccsg.Label.Overflow.NONE) ? _ccsg.Label.Overflow.CLAMP : this.overflow);
}
}
},
@@ -261,7 +262,7 @@ var Label = cc.Class({
},
_createSgNode: function () {
- var sgNode = new _ccsg.Label(this.string, this.file, _ccsg.Label.Type.TTF);
+ var sgNode = new _ccsg.Label(this.string, this.file);
// TODO
// sgNode.enableRichText = this.enableRichText;
diff --git a/cocos2d/core/components/CCLayout.js b/cocos2d/core/components/CCLayout.js
index 96941cd8d7..c9747ef0d2 100644
--- a/cocos2d/core/components/CCLayout.js
+++ b/cocos2d/core/components/CCLayout.js
@@ -29,9 +29,9 @@
*/
var Type = cc.Enum({
/**
- *@property {Number} BASIC
+ *@property {Number} NONE
*/
- BASIC: 0,
+ NONE: 0,
/**
* @property {Number} HORIZONTAL
*/
@@ -99,14 +99,27 @@ var Layout = cc.Class({
/**
* The layout type.
* @property {Layout.Type} layoutType
- * @default Layout.Type.BASIC
+ * @default Layout.Type.NONE
*/
layoutType: {
- default: Type.BASIC,
+ default: Type.NONE,
type: Type,
notify: function() {
this._doLayoutDirty();
- }
+ },
+ tooltip: 'i18n:COMPONENT.layout.layout_type'
+ },
+
+ /**
+ * Whether allow layout to adjust size.
+ * @property {Boolean} autoResize
+ * @default true
+ * @readonly
+ */
+ autoResize: {
+ default: true,
+ readonly: true,
+ tooltip: 'i18n:COMPONENT.layout.auto_resize'
},
/**
@@ -117,18 +130,32 @@ var Layout = cc.Class({
default: 0,
notify: function() {
this._doLayoutDirty();
- }
+ },
+ tooltip: 'i18n:COMPONENT.layout.margin'
},
/**
- * The distance between each element in layout.
- * @property {Number} spacing
+ * The distance in x-axis between each element in layout.
+ * @property {Number} spacingX
*/
- spacing: {
+ spacingX: {
default: 0,
notify: function() {
this._doLayoutDirty();
- }
+ },
+ tooltip: 'i18n:COMPONENT.layout.space_x'
+ },
+
+ /**
+ * The distance in y-axis between each element in layout.
+ * @property {Number} spacingY
+ */
+ spacingY: {
+ default: 0,
+ notify: function() {
+ this._doLayoutDirty();
+ },
+ tooltip: 'i18n:COMPONENT.layout.space_y'
},
/**
@@ -141,7 +168,8 @@ var Layout = cc.Class({
type: VerticalDirection,
notify: function() {
this._doLayoutDirty();
- }
+ },
+ tooltip: 'i18n:COMPONENT.layout.vertical_direction'
},
/**
@@ -154,7 +182,8 @@ var Layout = cc.Class({
type: HorizontalDirection,
notify: function() {
this._doLayoutDirty();
- }
+ },
+ tooltip: 'i18n:COMPONENT.layout.horizontal_direction'
},
},
@@ -183,6 +212,7 @@ var Layout = cc.Class({
children.forEach(function(child) {
child.on('size-changed', this._doLayoutDirty, this);
child.on('position-changed', this._doLayoutDirty, this);
+ child.on('anchor-changed', this._doLayoutDirty, this);
}.bind(this));
},
@@ -204,7 +234,7 @@ var Layout = cc.Class({
newWidth += child.width;
});
- newWidth += (children.length - 1) * this.spacing + 2 * this.margin;
+ newWidth += (children.length - 1) * this.spacingX + 2 * this.margin;
this.node.setContentSize(newWidth, layoutSize.height);
var leftBoundaryOfLayout = -layoutAnchor.x * newWidth;
@@ -213,14 +243,14 @@ var Layout = cc.Class({
leftBoundaryOfLayout = (1 - layoutAnchor.x) * newWidth;
}
- var nextX = leftBoundaryOfLayout + sign * this.margin - sign * this.spacing;
+ var nextX = leftBoundaryOfLayout + sign * this.margin - sign * this.spacingX;
children.forEach(function(child) {
var anchorX = child.anchorX;
if (this.horizontalDirection === HorizontalDirection.RIGHT_TO_LEFT) {
anchorX = 1 - child.anchorX;
}
- nextX = nextX + sign * anchorX * child.width + sign * this.spacing;
+ nextX = nextX + sign * anchorX * child.width + sign * this.spacingX;
child.setPosition(cc.p(nextX, child.y));
@@ -236,7 +266,7 @@ var Layout = cc.Class({
newHeight += child.height;
});
- newHeight += (children.length - 1) * this.spacing + 2 * this.margin;
+ newHeight += (children.length - 1) * this.spacingY + 2 * this.margin;
this.node.setContentSize(layoutSize.width, newHeight);
var bottomBoundaryOfLayout = -layoutAnchor.y * newHeight;
@@ -245,14 +275,14 @@ var Layout = cc.Class({
bottomBoundaryOfLayout = (1 - layoutAnchor.y) * newHeight;
}
- var nextY = bottomBoundaryOfLayout + sign * this.margin - sign * this.spacing;
+ var nextY = bottomBoundaryOfLayout + sign * this.margin - sign * this.spacingY;
children.forEach(function(child) {
var anchorY = child.anchorY;
if (this.verticalDirection === VerticalDirection.TOP_TO_BOTTOM) {
anchorY = 1 - child.anchorY;
}
- nextY = nextY + sign * anchorY * child.height + sign * this.spacing;
+ nextY = nextY + sign * anchorY * child.height + sign * this.spacingY;
child.setPosition(cc.p(child.x, nextY));
@@ -260,6 +290,34 @@ var Layout = cc.Class({
}.bind(this));
},
+ _doLayoutBasic: function(layoutAnchor, layoutSize, children) {
+ var allChildrenBoundingBox = null;
+
+ children.forEach(function(child){
+ if(!allChildrenBoundingBox){
+ allChildrenBoundingBox = child.getBoundingBoxToWorld();
+ } else {
+ allChildrenBoundingBox = cc.rectUnion(allChildrenBoundingBox, child.getBoundingBoxToWorld());
+ }
+ });
+
+ if(allChildrenBoundingBox) {
+ var leftBottomInParentSpace = this.node.parent.convertToNodeSpaceAR(cc.p(allChildrenBoundingBox.x, allChildrenBoundingBox.y));
+ var rightTopInParentSpace = this.node.parent.convertToNodeSpaceAR(cc.p(allChildrenBoundingBox.x + allChildrenBoundingBox.width,
+ allChildrenBoundingBox.y + allChildrenBoundingBox.height));
+
+ var newSize = cc.size(rightTopInParentSpace.x - leftBottomInParentSpace.x,
+ rightTopInParentSpace.y - leftBottomInParentSpace.y);
+
+ var layoutPosition = this.node.getPosition();
+ var newAnchor = cc.p((layoutPosition.x - leftBottomInParentSpace.x) / newSize.width,
+ (layoutPosition.y - leftBottomInParentSpace.y) / newSize.height);
+
+ this.node.setAnchorPoint(newAnchor);
+ this.node.setContentSize(newSize);
+ }
+ },
+
_doLayout: function() {
var children = this.node.children;
var layoutAnchor = this.node.getAnchorPoint();
@@ -269,11 +327,13 @@ var Layout = cc.Class({
this._doLayoutHorizontally(layoutAnchor, layoutSize, children);
} else if (this.layoutType === Type.VERTICAL) {
this._doLayoutVertically(layoutAnchor, layoutSize, children);
+ } else if (this.layoutType === Type.NONE) {
+ this._doLayoutBasic(layoutAnchor, layoutSize, children);
}
},
lateUpdate: function() {
- if (this._layoutDirty) {
+ if (this._layoutDirty && this.node.children.length > 0) {
this._doLayout();
this._layoutDirty = false;
}
diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js
index 0dcbe300aa..57cbb387b6 100644
--- a/cocos2d/core/components/CCMask.js
+++ b/cocos2d/core/components/CCMask.js
@@ -70,10 +70,6 @@ var Mask = cc.Class({
this.node.off('anchor-changed',this._onAnchorChanged,this);
},
- onDestroy: function () {
-
- },
-
_onContentSizeChanged: function() {
if(this._clippingStencil) {
this._clippingStencil.setContentSize(this.node._contentSize);
@@ -96,6 +92,6 @@ var Mask = cc.Class({
}
},
- });
+});
- cc.Mask = module.exports = Mask;
+cc.Mask = module.exports = Mask;
diff --git a/cocos2d/core/components/CCScrollView.js b/cocos2d/core/components/CCScrollView.js
index 3b5cd29177..365f5fb7b1 100644
--- a/cocos2d/core/components/CCScrollView.js
+++ b/cocos2d/core/components/CCScrollView.js
@@ -22,8 +22,6 @@
THE SOFTWARE.
****************************************************************************/
-var EventTarget = require('../event/event-target');
-
var NUMBER_OF_GATHERED_TOUCHES_FOR_MOVE_SPEED = 5;
var OUT_OF_BOUNDARY_BREAKING_FACTOR = 0.05;
var EPSILON = 1e-7;
@@ -49,7 +47,6 @@ var getTimeInMilliseconds = function() {
var ScrollView = cc.Class({
name: 'cc.ScrollView',
extends: require('./CCComponent'),
- mixins: [EventTarget],
editor: CC_EDITOR && {
menu: 'i18n:MAIN_MENU.component.ui/ScrollView',
@@ -57,9 +54,6 @@ var ScrollView = cc.Class({
},
ctor: function() {
-
- this._touchListener = null;
-
this._topBoundary = 0;
this._bottomBoundary = 0;
this._leftBoundary = 0;
@@ -193,9 +187,9 @@ var ScrollView = cc.Class({
applyToVertical: true,
});
- if(timeInSecond) {
+ if (timeInSecond) {
this._startAutoScroll(moveDelta, timeInSecond, attenuated !== false);
- }else {
+ } else {
this._moveContent(moveDelta, true);
}
},
@@ -214,9 +208,9 @@ var ScrollView = cc.Class({
applyToVertical: true,
});
- if(timeInSecond) {
+ if (timeInSecond) {
this._startAutoScroll(moveDelta, timeInSecond, attenuated !== false);
- }else {
+ } else {
this._moveContent(moveDelta);
}
},
@@ -235,9 +229,9 @@ var ScrollView = cc.Class({
applyToVertical: false,
});
- if(timeInSecond) {
+ if (timeInSecond) {
this._startAutoScroll(moveDelta, timeInSecond, attenuated !== false);
- }else {
+ } else {
this._moveContent(moveDelta);
}
},
@@ -256,9 +250,9 @@ var ScrollView = cc.Class({
applyToVertical: false,
});
- if(timeInSecond) {
+ if (timeInSecond) {
this._startAutoScroll(moveDelta, timeInSecond, attenuated !== false);
- }else {
+ } else {
this._moveContent(moveDelta);
}
},
@@ -277,9 +271,9 @@ var ScrollView = cc.Class({
applyToVertical: true,
});
- if(timeInSecond) {
+ if (timeInSecond) {
this._startAutoScroll(moveDelta, timeInSecond, attenuated !== false);
- }else {
+ } else {
this._moveContent(moveDelta);
}
},
@@ -298,9 +292,9 @@ var ScrollView = cc.Class({
applyToVertical: true,
});
- if(timeInSecond) {
+ if (timeInSecond) {
this._startAutoScroll(moveDelta, timeInSecond, attenuated !== false);
- }else {
+ } else {
this._moveContent(moveDelta);
}
},
@@ -319,9 +313,9 @@ var ScrollView = cc.Class({
applyToVertical: true,
});
- if(timeInSecond) {
+ if (timeInSecond) {
this._startAutoScroll(moveDelta, timeInSecond, attenuated !== false);
- }else {
+ } else {
this._moveContent(moveDelta);
}
},
@@ -340,9 +334,9 @@ var ScrollView = cc.Class({
applyToVertical: true,
});
- if(timeInSecond) {
+ if (timeInSecond) {
this._startAutoScroll(moveDelta, timeInSecond, attenuated !== false);
- }else {
+ } else {
this._moveContent(moveDelta);
}
},
@@ -362,9 +356,9 @@ var ScrollView = cc.Class({
applyToVertical: false,
});
- if(timeInSecond) {
+ if (timeInSecond) {
this._startAutoScroll(moveDelta, timeInSecond, attenuated !== false);
- }else {
+ } else {
this._moveContent(moveDelta);
}
},
@@ -377,16 +371,16 @@ var ScrollView = cc.Class({
* the content will jump to the percent position of ScrollView immediately.
* @param {Boolean} [attenuated=true] - Whether the scroll acceleration attenuated, default is true.
*/
- scrollTo: function(anchor, timeInSecond, attenuated){
+ scrollTo: function(anchor, timeInSecond, attenuated) {
var moveDelta = this._calculateMovePercentDelta({
anchor: anchor,
applyToHorizontal: true,
applyToVertical: true,
});
- if(timeInSecond) {
+ if (timeInSecond) {
this._startAutoScroll(moveDelta, timeInSecond, attenuated !== false);
- }else {
+ } else {
this._moveContent(moveDelta);
}
},
@@ -406,9 +400,9 @@ var ScrollView = cc.Class({
applyToVertical: true,
});
- if(timeInSecond) {
+ if (timeInSecond) {
this._startAutoScroll(moveDelta, timeInSecond, attenuated !== false);
- }else {
+ } else {
this._moveContent(moveDelta);
}
},
@@ -441,15 +435,10 @@ var ScrollView = cc.Class({
//private methods
_registerEvent: function() {
- this._touchListener = cc.EventListener.create({
- event: cc.EventListener.TOUCH_ONE_BY_ONE,
- swallowTouches: true,
- onTouchBegan: this._onTouchBegan.bind(this),
- onTouchEnded: this._onTouchEnded.bind(this),
- onTouchMoved: this._onTouchMoved.bind(this),
- onTouchCancelled: this._onTouchCancelled.bind(this)
- });
- cc.eventManager.addListener(this._touchListener, this.node._sgNode);
+ this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchBegan, this);
+ this.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMoved, this);
+ this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnded, this);
+ this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancelled, this);
},
_calculateMovePercentDelta: function(options) {
@@ -465,12 +454,12 @@ var ScrollView = cc.Class({
var leftDeta = Math.abs(this._getContentLeftBoundary() - this._leftBoundary);
var moveDelta = cc.p(0, 0);
- if(applyToHorizontal) {
+ if (applyToHorizontal) {
moveDelta.x = (contentSize.width - scrollSize.width) * anchor.x - leftDeta;
}
- if(applyToVertical) {
- moveDelta.y = (contentSize.height - scrollSize.height) * anchor.y - bottomDeta;
+ if (applyToVertical) {
+ moveDelta.y = (contentSize.height - scrollSize.height) * anchor.y - bottomDeta;
}
moveDelta = cc.pNeg(moveDelta);
@@ -478,7 +467,7 @@ var ScrollView = cc.Class({
},
_calculateBoundary: function() {
- if(this.content){
+ if (this.content) {
var scrollViewSize = this.node.getContentSize();
var leftBottomPosition = this._convertToContentParentSpace(cc.p(0, 0));
@@ -511,7 +500,8 @@ var ScrollView = cc.Class({
},
// touch event handler
- _onTouchBegan: function(touch) {
+ _onTouchBegan: function(event) {
+ var touch = event.touch;
var hit = this._hitTest(touch.getLocation());
if (hit && this.content) {
this._handlePressLogic(touch);
@@ -520,32 +510,51 @@ var ScrollView = cc.Class({
return hit;
},
- _onTouchMoved: function(touch) {
+ _cancelButtonClick: function(touch) {
+ var deltaMove = touch.getDelta();
+ var needCancelTouch = false;
+ if (cc.sys.isMobile) {
+ //FIXME: touch move delta should be calculated by DPI.
+ var TOUCH_CANCEL_POINT = 7;
+ if (cc.pLength(deltaMove) > TOUCH_CANCEL_POINT) {
+ needCancelTouch = true;
+ }
+ } else {
+ needCancelTouch = true;
+ }
+
+ return needCancelTouch;
+ },
+
+ _onTouchMoved: function(event) {
+ var touch = event.touch;
if (this.content) {
+ var buttonComponent = event.target.getComponent(cc.Button);
+ if (buttonComponent && this._cancelButtonClick(touch)) {
+ buttonComponent._cancelButtonClick();
+ }
this._handleMoveLogic(touch);
}
},
- _onTouchEnded: function(touch) {
- if(this.content){
+ _onTouchEnded: function(event) {
+ var touch = event.touch;
+ if (this.content) {
this._handleReleaseLogic(touch);
}
},
- _onTouchCancelled: function(touch) {
- this._handlePressLogic(touch);
+ _onTouchCancelled: function(event) {
+ var touch = event.touch;
+ if(this.content){
+ this._handleReleaseLogic(touch);
+ }
},
_handleMoveLogic: function(touch) {
- var currPt = touch.getLocation();
- var prevPt = touch.getPreviousLocation();
- if (!this._hitTest(currPt) || !this._hitTest(prevPt)) {
- return;
- }
+ var deltaMove = touch.getDelta();
- var deltaMove = cc.pSub(currPt, prevPt);
this._scrollChildren(deltaMove);
-
this._gatherTouchMove(deltaMove);
},
@@ -625,13 +634,8 @@ var ScrollView = cc.Class({
},
_handleReleaseLogic: function(touch) {
- var currPt = touch.getLocation();
- var prevPt = touch.getPreviousLocation();
-
- if (this._hitTest(currPt) && this._hitTest(prevPt)) {
- var delta = cc.pSub(currPt, prevPt);
- this._gatherTouchMove(delta);
- }
+ var delta = touch.getDelta();
+ this._gatherTouchMove(delta);
var bounceBackStarted = this._startBounceBackIfNeeded();
@@ -767,7 +771,7 @@ var ScrollView = cc.Class({
return a + b;
}, totalTime);
- if (totalTime === 0 || totalTime >= 0.5) {
+ if (totalTime <= 0 || totalTime >= 0.5) {
return cc.p(0, 0);
}
@@ -900,10 +904,6 @@ var ScrollView = cc.Class({
this._processAutoScrolling(dt);
}
},
-
- onDestroy: function() {
- if (this._touchListener) cc.eventManager.removeListener(this._touchListener);
- }
});
cc.ScrollView = module.exports = ScrollView;
diff --git a/cocos2d/core/components/CCSprite.js b/cocos2d/core/components/CCSprite.js
index dfe13363f3..eb02f8aa3a 100644
--- a/cocos2d/core/components/CCSprite.js
+++ b/cocos2d/core/components/CCSprite.js
@@ -61,7 +61,7 @@ var Sprite = cc.Class({
/**
* The sprite frame of the sprite.
- * @property sprite
+ * @property spriteFrame
* @type {SpriteFrame}
*/
spriteFrame: {
@@ -72,14 +72,13 @@ var Sprite = cc.Class({
var lastSprite = this._spriteFrame;
this._spriteFrame = value;
if (this._sgNode) {
- this._applySprite(this._sgNode, lastSprite);
+ this._applySpriteFrame(this._sgNode, lastSprite);
// color cleared after reset texture, should reapply color
this._sgNode.setColor(this.node._color);
this._sgNode.setOpacity(this.node._opacity);
}
},
type: cc.SpriteFrame,
- tooltip: 'i18n:COMPONENT.sprite.sprite_frame',
},
/**
@@ -126,6 +125,7 @@ var Sprite = cc.Class({
return cc.size(sgNode.width, sgNode.height);
},
visible: false,
+ override: true
}
},
@@ -155,7 +155,7 @@ var Sprite = cc.Class({
* @return {Boolean} True if 9-slice is enabled, false otherwise.
*/
isScale9Enabled: function(){
- return this.type === cc.SpriteType.SLICED
+ return this.type === cc.SpriteType.SLICED;
},
/**
@@ -313,51 +313,49 @@ var Sprite = cc.Class({
}
},
- _applyCapInset: function (node) {
- if (this._type === SpriteType.SLICED) {
- var node = node || this._sgNode;
- node.setInsetTop(this._spriteFrame.insetTop);
- node.setInsetBottom(this._spriteFrame.insetBottom);
- node.setInsetRight(this._spriteFrame.insetRight);
- node.setInsetLeft(this._spriteFrame.insetLeft);
+ _applyCapInset: function (sgNode) {
+ if (this._type === SpriteType.SLICED && this._spriteFrame) {
+ sgNode = sgNode || this._sgNode;
+ sgNode.setInsetTop(this._spriteFrame.insetTop);
+ sgNode.setInsetBottom(this._spriteFrame.insetBottom);
+ sgNode.setInsetRight(this._spriteFrame.insetRight);
+ sgNode.setInsetLeft(this._spriteFrame.insetLeft);
}
},
- _applySpriteSize: function (node) {
- var node = node || this._sgNode;
- if (this._useOriginalSize) {
+ _applySpriteSize: function (sgNode) {
+ sgNode = sgNode || this._sgNode;
+ if (this._useOriginalSize && this._spriteFrame) {
var rect = this._spriteFrame.getRect();
- node.setContentSize(cc.size(rect.width, rect.height));
+ this.node.setContentSize(cc.size(rect.width, rect.height));
}
else {
- node.setContentSize(this.node.getContentSize(true));
+ this.node.setContentSize(this.node.getContentSize(true));
}
},
- _applySprite: function (sgNode, oldSprite) {
- if (oldSprite && oldSprite.off) {
- oldSprite.off('load', this._applyCapInset, this);
+ _onSpriteFrameLoaded: function (event, sgNode) {
+ var self = this;
+ sgNode = sgNode || this._sgNode;
+ sgNode.setSpriteFrame(self._spriteFrame);
+ self._applyCapInset(sgNode);
+ self._applySpriteSize();
+ if ( this.enabledInHierarchy && !sgNode.isVisible() ) {
+ sgNode.setVisible(true);
+ }
+ },
+
+ _applySpriteFrame: function (sgNode, oldFrame) {
+ if (oldFrame && oldFrame.off) {
+ oldFrame.off('load', this._onSpriteFrameLoaded, this);
}
if (this._spriteFrame) {
- if (!sgNode.isVisible()) {
- sgNode.setVisible(true);
- }
-
- sgNode.setSpriteFrame(this._spriteFrame);
- var locLoaded = this._spriteFrame.textureLoaded();
- if (!locLoaded) {
- if (!this._useOriginalSize) {
- sgNode.setContentSize(this.node.getContentSize(true));
- }
- this._spriteFrame.once('load', function () {
- this._applyCapInset();
- this._applySpriteSize();
- }, this);
+ if (this._spriteFrame.textureLoaded()) {
+ this._onSpriteFrameLoaded(null, sgNode);
}
else {
- this._applyCapInset(sgNode);
- this._applySpriteSize(sgNode);
+ this._spriteFrame.once('load', this._onSpriteFrameLoaded, this);
}
}
else {
@@ -372,13 +370,29 @@ var Sprite = cc.Class({
_createSgNode: function () {
var sgNode = new cc.Scale9Sprite();
+
+ this._applySpriteFrame(sgNode, null);
+
+ // should keep the size of the sg node the same as entity,
+ // otherwise setContentSize may not take effect
+ sgNode.setContentSize(this.node.getContentSize(true));
+ this._applySpriteSize(sgNode);
+
sgNode.setRenderingType(this._type);
- this._applySprite(sgNode, null);
+
return sgNode;
},
_resized: function () {
- this.useOriginalSize = false;
+ if (this._useOriginalSize && this._spriteFrame) {
+ var rect = this._spriteFrame.getRect();
+ var expectedW = rect.width;
+ var expectedH = rect.height;
+ var actualSize = this.node.getContentSize();
+ if (expectedW !== actualSize.width || expectedH !== actualSize.height) {
+ this.useOriginalSize = false;
+ }
+ }
},
});
diff --git a/cocos2d/core/event/event-target.js b/cocos2d/core/event/event-target.js
index 1495acee96..1045dfa090 100644
--- a/cocos2d/core/event/event-target.js
+++ b/cocos2d/core/event/event-target.js
@@ -1,6 +1,5 @@
var EventListeners = require('./event-listeners');
-var Event = require('./event');
-var EventCustom = Event.EventCustom;
+require('./event');
var JS = cc.js;
var cachedArray = new Array(16);
@@ -270,7 +269,7 @@ JS.mixin(EventTarget.prototype, {
*/
emit: function (message, detail) {
if ( typeof message === 'string' ) {
- var event = new EventCustom(message);
+ var event = new cc.Event.EventCustom(message);
event.detail = detail;
_doSendEvent(this, event);
}
diff --git a/cocos2d/labels/CCSGLabel.js b/cocos2d/core/label/CCSGLabel.js
similarity index 97%
rename from cocos2d/labels/CCSGLabel.js
rename to cocos2d/core/label/CCSGLabel.js
index 97c4723f08..404afae8be 100644
--- a/cocos2d/labels/CCSGLabel.js
+++ b/cocos2d/core/label/CCSGLabel.js
@@ -109,7 +109,7 @@ _ccsg.Label = _ccsg.Node.extend({
_vAlign: cc.VerticalTextAlignment.TOP, //0 bottom,1 center, 2 top
_string: "",
_fontSize: 40,
- _overFlow: 0, //0 clamp, 1 shrink 2, resize to content
+ _overFlow: 1, //see _ccsg.Label.Overflow
_isWrapText: true,
_spacingX: 0,
@@ -130,13 +130,11 @@ _ccsg.Label = _ccsg.Node.extend({
_className: "Label",
//fontHandle it is a font name or bmfont file.
- ctor: function(string, fontHandle, type) {
+ ctor: function(string, fontHandle) {
EventTarget.call(this);
fontHandle = fontHandle || "";
this._fontHandle = fontHandle;
- type = type || 0;
- this._labelType = type;
string = string || "";
this._string = string;
@@ -145,13 +143,8 @@ _ccsg.Label = _ccsg.Node.extend({
this.setContentSize(cc.size(128, 128));
this._blendFunc = cc.BlendFunc._alphaNonPremultiplied();
- //init bmfont
- if (type === 1) {
- this._initBMFontWithString(this._string, this._fontHandle);
- } else {
- this.setFontFileOrFamily(fontHandle);
- this.setString(this._string);
- }
+ this.setFontFileOrFamily(fontHandle);
+ this.setString(this._string);
},
_resetBMFont: function() {
@@ -217,6 +210,11 @@ _ccsg.Label = _ccsg.Node.extend({
},
setString: function(string) {
+ //convert param to string
+ if (typeof string !== 'string') {
+ string = '' + string;
+ }
+
if (this._string === string) return;
this._string = string;
this._notifyLabelSkinDirty();
@@ -233,7 +231,7 @@ _ccsg.Label = _ccsg.Node.extend({
enableWrapText: function(enabled) {
if (this._isWrapText === enabled) return;
//when label is in resize mode, wrap is disabled.
- if (this._overFlow === _ccsg.Label.Overflow.RESIZE) {
+ if (this._overFlow === _ccsg.Label.Overflow.RESIZE_HEIGHT) {
return;
}
this._isWrapText = enabled;
@@ -260,7 +258,7 @@ _ccsg.Label = _ccsg.Node.extend({
setOverflow: function(overflow) {
if (this._overFlow === overflow) return;
this._overFlow = overflow;
- if (this._overFlow === _ccsg.Label.Overflow.RESIZE) {
+ if (this._overFlow === _ccsg.Label.Overflow.RESIZE_HEIGHT) {
this._setDimensions(this._labelDimensions.width, 0);
this._isWrapText = true;
}
@@ -304,7 +302,7 @@ _ccsg.Label = _ccsg.Node.extend({
//specify font family name directly
if (extName === null) {
this._fontHandle = fontHandle;
- this._labelType = _ccsg.Label.Type.TTF;
+ this._labelType = _ccsg.Label.Type.SystemFont;
this._notifyLabelSkinDirty();
this._isUseSystemFont = true;
return;
@@ -372,7 +370,8 @@ _ccsg.Label = _ccsg.Node.extend({
setContentSize: function(size, height) {
var oldWidth = this._contentSize.width;
var oldHeight = this._contentSize.height;
- if (this._labelType === _ccsg.Label.Type.TTF) {
+ if (this._labelType === _ccsg.Label.Type.TTF ||
+ this._labelType === _ccsg.Label.Type.SystemFont) {
_ccsg.Node.prototype.setContentSize.call(this, size, height);
if (oldWidth === this._contentSize.width && oldHeight === this._contentSize.height) {
return;
@@ -424,7 +423,8 @@ _ccsg.Label = _ccsg.Node.extend({
this._updateContent();
this.setColor(this.color);
this._labelSkinDirty = false;
- } else if (this._labelType === _ccsg.Label.Type.TTF) {
+ } else if (this._labelType === _ccsg.Label.Type.TTF
+ || this._labelType === _ccsg.Label.Type.SystemFont) {
this._labelSkinDirty = true;
}
} else {
@@ -612,7 +612,7 @@ cc.BMFontHelper = {
},
_setDimensions: function(width, height) {
- if (this._overFlow === _ccsg.Label.Overflow.RESIZE) {
+ if (this._overFlow === _ccsg.Label.Overflow.RESIZE_HEIGHT) {
height = 0;
}
if (height !== this._labelHeight || width !== this._labelWidth) {
@@ -1094,11 +1094,13 @@ cc.js.mixin(_p, cc.BMFontHelper);
_ccsg.Label.Type = cc.Enum({
TTF: 0,
- BMFont: 1
+ BMFont: 1,
+ SystemFont: 2
});
_ccsg.Label.Overflow = cc.Enum({
- CLAMP: 0,
- SHRINK: 1,
- RESIZE: 2,
- NONE: 3
+ //TODO: NONE is not implemented yet
+ NONE: 0,
+ CLAMP: 1,
+ SHRINK: 2,
+ RESIZE_HEIGHT: 3
});
diff --git a/cocos2d/labels/CCSGLabelCanvasRenderCmd.js b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
similarity index 94%
rename from cocos2d/labels/CCSGLabelCanvasRenderCmd.js
rename to cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
index 319d120d44..2a889f1c2c 100644
--- a/cocos2d/labels/CCSGLabelCanvasRenderCmd.js
+++ b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
@@ -131,6 +131,7 @@
if (label_symbolRex.test(sLine || tmpText)) {
result = label_lastWordRex.exec(sText);
fuzzyLen -= result ? result[0].length : 0;
+ if (fuzzyLen === 0) fuzzyLen = 1;
sLine = text.substr(fuzzyLen);
sText = text.substr(0, fuzzyLen);
@@ -195,7 +196,8 @@
paragraphLength.push(textMetric.width);
}
- if (_ccsg.Label.Overflow.CLAMP == node._overFlow) {
+ //FIXME: add normal overflow
+ if (_ccsg.Label.Overflow.CLAMP === node._overFlow) {
if (node._isWrapText) {
this._splitedStrings = [];
for (var i = 0; i < paragraphedStrings.length; ++i) {
@@ -204,7 +206,7 @@
} else {
this._splitedStrings = paragraphedStrings;
}
- } else if (_ccsg.Label.Overflow.RESIZE == node._overFlow) {
+ } else if (_ccsg.Label.Overflow.RESIZE_HEIGHT === node._overFlow) {
//todo fix it
if (node._isWrapText) {
this._splitedStrings = [];
@@ -218,15 +220,7 @@
canvasSizeY = this._splitedStrings.length * this._getLineHeight();
node.setContentSize(cc.size(canvasSizeX, canvasSizeY));
}
- } else if(_ccsg.Label.Overflow.NONE == node._overFlow) {
- this._splitedStrings = paragraphedStrings;
- for (var i = 0; i < paragraphedStrings.length; ++i) {
- var paraLength = ctx.measureText(paragraphedStrings[i]).width;
- canvasSizeX = canvasSizeX > paraLength ? canvasSizeX : paraLength;
- }
- canvasSizeY = this._splitedStrings.length * this._getLineHeight();
- node.setContentSize(cc.size(canvasSizeX, canvasSizeY));
- } else{
+ } else if(_ccsg.Label.Overflow.SHRINK === node._overFlow) {
this._splitedStrings = paragraphedStrings;
//shrink
if (node._isWrapText) {
@@ -256,7 +250,24 @@
fontDesc = this._drawFontsize.toString() + "px " + fontFamily;
this._splitedStrings = paragraphedStrings;
}
-
+ } else if(_ccsg.Label.Overflow.NONE == node._overFlow) {
+ this._splitedStrings = paragraphedStrings;
+ for (var i = 0; i < paragraphedStrings.length; ++i) {
+ var paraLength = ctx.measureText(paragraphedStrings[i]).width;
+ canvasSizeX = canvasSizeX > paraLength ? canvasSizeX : paraLength;
+ }
+ canvasSizeY = this._splitedStrings.length * this._getLineHeight();
+ node.setContentSize(cc.size(canvasSizeX, canvasSizeY));
+ } else {
+ //others treat it as clamp
+ if (node._isWrapText) {
+ this._splitedStrings = [];
+ for (var i = 0; i < paragraphedStrings.length; ++i) {
+ this._splitedStrings = this._splitedStrings.concat(this._fragmentText(paragraphedStrings[i], canvasSizeX, ctx));
+ }
+ } else {
+ this._splitedStrings = paragraphedStrings;
+ }
}
this._labelCanvas.width = canvasSizeX;
@@ -315,7 +326,8 @@
proto._rebuildLabelSkin = function() {
var node = this._node;
if (node._labelSkinDirty) {
- if(node._labelType === _ccsg.Label.Type.TTF){
+ if(node._labelType === _ccsg.Label.Type.TTF ||
+ node._labelType === _ccsg.Label.Type.SystemFont){
this._bakeLabel();
this._prepareQuad();
}else {
@@ -352,7 +364,8 @@
var node = this._node;
- if (node._labelType === _ccsg.Label.Type.TTF) {
+ if (node._labelType === _ccsg.Label.Type.TTF ||
+ node._labelType === _ccsg.Label.Type.SystemFont) {
var locDisplayOpacity = this._displayedOpacity;
var alpha = locDisplayOpacity / 255;
//var locTexture = this._labelTexture;
diff --git a/cocos2d/labels/CCSGLabelWebGLRenderCmd.js b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js
similarity index 97%
rename from cocos2d/labels/CCSGLabelWebGLRenderCmd.js
rename to cocos2d/core/label/CCSGLabelWebGLRenderCmd.js
index 6fd4b48d15..e75c946c9c 100644
--- a/cocos2d/labels/CCSGLabelWebGLRenderCmd.js
+++ b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js
@@ -60,7 +60,8 @@
var node = this._node;
this._rebuildLabelSkin();
- if(node._labelType === _ccsg.Label.Type.TTF){
+ if(node._labelType === _ccsg.Label.Type.TTF ||
+ node._labelType === _ccsg.Label.Type.SystemFont){
var gl = ctx || cc._renderContext ;
this._shaderProgram.use();
diff --git a/cocos2d/core/label/FNTLoader.js b/cocos2d/core/label/FNTLoader.js
new file mode 100644
index 0000000000..eb73086bd2
--- /dev/null
+++ b/cocos2d/core/label/FNTLoader.js
@@ -0,0 +1,103 @@
+cc._fntLoader = {
+ INFO_EXP: /info [^\n]*(\n|$)/gi,
+ COMMON_EXP: /common [^\n]*(\n|$)/gi,
+ PAGE_EXP: /page [^\n]*(\n|$)/gi,
+ CHAR_EXP: /char [^\n]*(\n|$)/gi,
+ KERNING_EXP: /kerning [^\n]*(\n|$)/gi,
+ ITEM_EXP: /\w+=[^ \r\n]+/gi,
+ INT_EXP: /^[\-]?\d+$/,
+
+ _parseStrToObj: function (str) {
+ var arr = str.match(this.ITEM_EXP);
+ var obj = {};
+ if (arr) {
+ for (var i = 0, li = arr.length; i < li; i++) {
+ var tempStr = arr[i];
+ var index = tempStr.indexOf("=");
+ var key = tempStr.substring(0, index);
+ var value = tempStr.substring(index + 1);
+ if (value.match(this.INT_EXP)) value = parseInt(value);
+ else if (value[0] === '"') value = value.substring(1, value.length - 1);
+ obj[key] = value;
+ }
+ }
+ return obj;
+ },
+
+ /**
+ * Parse Fnt string.
+ * @param fntStr
+ * @param url
+ * @returns {{}}
+ */
+ parseFnt: function (fntStr, url) {
+ var self = this, fnt = {};
+ //padding
+ var infoObj = self._parseStrToObj(fntStr.match(self.INFO_EXP)[0]);
+ var paddingArr = infoObj["padding"].split(",");
+ var padding = {
+ left: parseInt(paddingArr[0]),
+ top: parseInt(paddingArr[1]),
+ right: parseInt(paddingArr[2]),
+ bottom: parseInt(paddingArr[3])
+ };
+
+ //common
+ var commonObj = self._parseStrToObj(fntStr.match(self.COMMON_EXP)[0]);
+ fnt.commonHeight = commonObj["lineHeight"];
+ //font size
+ fnt.fontSize = infoObj["size"];
+ if (cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
+ var texSize = cc.configuration.getMaxTextureSize();
+ if (commonObj["scaleW"] > texSize.width || commonObj["scaleH"] > texSize.height)
+ cc.log("cc.LabelBMFont._parseCommonArguments(): page can't be larger than supported");
+ }
+ if (commonObj["pages"] !== 1) cc.log("cc.LabelBMFont._parseCommonArguments(): only supports 1 page");
+
+ //page
+ var pageObj = self._parseStrToObj(fntStr.match(self.PAGE_EXP)[0]);
+ if (pageObj["id"] !== 0) cc.log("cc.LabelBMFont._parseImageFileName() : file could not be found");
+ fnt.atlasName = cc.path.changeBasename(url, pageObj["file"]);
+
+ //char
+ var charLines = fntStr.match(self.CHAR_EXP);
+ var fontDefDictionary = fnt.fontDefDictionary = {};
+ for (var i = 0, li = charLines.length; i < li; i++) {
+ var charObj = self._parseStrToObj(charLines[i]);
+ var charId = charObj["id"];
+ fontDefDictionary[charId] = {
+ rect: {x: charObj["x"], y: charObj["y"], width: charObj["width"], height: charObj["height"]},
+ xOffset: charObj["xoffset"],
+ yOffset: charObj["yoffset"],
+ xAdvance: charObj["xadvance"]
+ };
+ }
+
+ //kerning
+ var kerningDict = fnt.kerningDict = {};
+ var kerningLines = fntStr.match(self.KERNING_EXP);
+ if (kerningLines) {
+ for (var i = 0, li = kerningLines.length; i < li; i++) {
+ var kerningObj = self._parseStrToObj(kerningLines[i]);
+ kerningDict[(kerningObj["first"] << 16) | (kerningObj["second"] & 0xffff)] = kerningObj["amount"];
+ }
+ }
+ return fnt;
+ },
+
+ /**
+ * load the fnt
+ * @param realUrl
+ * @param url
+ * @param res
+ * @param cb
+ */
+ load: function (realUrl, url, res, cb) {
+ var self = this;
+ cc.loader.loadTxt(realUrl, function (err, txt) {
+ if (err) return cb(err);
+ cb(null, self.parseFnt(txt, url));
+ });
+ }
+};
+cc.loader.register(["fnt"], cc._fntLoader);
\ No newline at end of file
diff --git a/cocos2d/core/platform/CCAssetLibrary.js b/cocos2d/core/platform/CCAssetLibrary.js
index 61e9f45fef..ceeb0cb01e 100644
--- a/cocos2d/core/platform/CCAssetLibrary.js
+++ b/cocos2d/core/platform/CCAssetLibrary.js
@@ -25,6 +25,8 @@ var _uuidToCallbacks = new CallbacksInvoker();
// temp deserialize info
var _tdInfo = new cc.deserialize.Details();
+var _cc_loader_loadJson = cc.loader.loadJson.bind(cc.loader);
+
// create a loading context which reserves all relevant parameters
function LoadingHandle (readMainCache, writeMainCache, recordAssets, deserializeInfo) {
//this.readMainCache = readMainCache;
@@ -92,7 +94,8 @@ var AssetLibrary = {
* @param {Boolean} options.writeMainCache - Default is true. If true, the result will cache to AssetLibrary, and MUST be unload by user manually.
* @param {Asset} options.existingAsset - load to existing asset, this argument is only available in editor
* @param {Boolean} options.recordAssets - Default is false. If true, tracking statistics associated with the assets which needs to preload(All the assets contains "urls" but dont have "_rawFiles")
- * @param {deserialize.Details} options.deserializeInfo - specified a DeserializeInfo object if you want
+ * @param {deserialize.Details} options.deserializeInfo - specified a DeserializeInfo object if you want,
+ * this parameter is only available in editor.
* @private
*/
loadAsset: function (uuid, callback, options) {
@@ -274,7 +277,7 @@ var AssetLibrary = {
if (!shouldLoadByEngine) {
return callback(new Error('Should not load raw file in AssetLibrary, uuid: ' + uuid));
}
- LoadManager.loadByLoader(cc.loader.loadJson.bind(cc.loader), url, function (error, json) {
+ LoadManager.loadByLoader(_cc_loader_loadJson, url, function (error, json) {
onload(error, json, url);
});
}
@@ -285,7 +288,7 @@ var AssetLibrary = {
if (info.raw) {
return callback(new Error('Should not load raw file in AssetLibrary, uuid: ' + uuid));
}
- LoadManager.loadByLoader(cc.loader.loadJson.bind(cc.loader), info.url, function (error, json) {
+ LoadManager.loadByLoader(_cc_loader_loadJson, info.url, function (error, json) {
onload(error, json, info.url);
});
}
@@ -366,13 +369,12 @@ var AssetLibrary = {
callback();
callback = null;
}
+
+ obj[prop] = obj[prop]; // ensures forEach worked
return;
}
else if (isRawAsset) {
- // HACK - https://github.com/fireball-x/fireball/issues/668
- var isImg = cc.loader._checkIsImageURL(dependsUrl);
- var loadFunc = isImg ? cc.loader.loadImg : cc.loader.load;
- loadFunc.call(cc.loader, dependsUrl, function (err, assets) {
+ cc.loader.load(dependsUrl, function (err, assets) {
if (err) {
cc.error('[AssetLibrary] Failed to load "%s"', dependsUrl);
obj[prop] = '';
@@ -442,7 +444,7 @@ var AssetLibrary = {
return Object;
};
- var tdInfo = handle.deserializeInfo || _tdInfo;
+ var tdInfo = cc.sys.isNative ? new cc.deserialize.Details() : (handle.deserializeInfo || _tdInfo);
var asset = cc.deserialize(json, tdInfo, {
classFinder: classFinder,
@@ -540,8 +542,7 @@ var AssetLibrary = {
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap
* https://github.com/TooTallNate/node-weak
*
- * @property _uuidToAsset
- * @type {object}
+ * @property {object} _uuidToAsset
* @private
*/
AssetLibrary._uuidToAsset = {};
diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js
index 903b923bf3..a7bde0a31b 100644
--- a/cocos2d/core/platform/CCClass.js
+++ b/cocos2d/core/platform/CCClass.js
@@ -645,9 +645,9 @@ function boundSuperCalls (baseClass, options) {
* !#en Defines a FireClass using the given specification, please see [Class](/en/scripting/class/) for details.
* !#zh 定义一个 FireClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/zh/scripting/class/)。
*
+ * @class Class
* @param {Object} options
* @return {Function} - the created class
- * @memberof cc
*
* @example
// define base class
@@ -718,7 +718,7 @@ function FireClass (options) {
if (properties) {
// 预处理属性
- preprocessAttrs(properties, name);
+ preprocessAttrs(properties, name, cls);
for (var propName in properties) {
var val = properties[propName];
diff --git a/cocos2d/core/platform/CCCommon.js b/cocos2d/core/platform/CCCommon.js
index e121fd5ca5..52a19dc939 100644
--- a/cocos2d/core/platform/CCCommon.js
+++ b/cocos2d/core/platform/CCCommon.js
@@ -38,176 +38,622 @@ cc.associateWithNative = function (jsObj, superclass) {
/**
* Key map for keyboard event
- *
- * @constant
+ * @enum KEY
+ * @readonly
* @type {Object}
* @example {@link utils/api/engine/docs/cocos2d/core/platform/CCCommon/KEY.js}
*/
cc.KEY = {
+ /**
+ * @property {Number} none
+ * @readonly
+ */
none:0,
// android
+ /**
+ * @property {Number} back
+ * @readonly
+ */
back:6,
+ /**
+ * @property {Number} menu
+ * @readonly
+ */
menu:18,
+ /**
+ * @property {Number} backspace
+ * @readonly
+ */
backspace:8,
+ /**
+ * @property {Number} tab
+ * @readonly
+ */
tab:9,
+ /**
+ * @property {Number} enter
+ * @readonly
+ */
enter:13,
+ /**
+ * @property {Number} shift
+ * @readonly
+ */
shift:16, //should use shiftkey instead
+ /**
+ * @property {Number} ctrl
+ * @readonly
+ */
ctrl:17, //should use ctrlkey
+ /**
+ * @property {Number} alt
+ * @readonly
+ */
alt:18, //should use altkey
+ /**
+ * @property {Number} pause
+ * @readonly
+ */
pause:19,
+ /**
+ * @property {Number} capslock
+ * @readonly
+ */
capslock:20,
-
+ /**
+ * @property {Number} escape
+ * @readonly
+ */
escape:27,
+ /**
+ * @property {Number} space
+ * @readonly
+ */
space:32,
+ /**
+ * @property {Number} pageup
+ * @readonly
+ */
pageup:33,
+ /**
+ * @property {Number} pagedown
+ * @readonly
+ */
pagedown:34,
+ /**
+ * @property {Number} end
+ * @readonly
+ */
end:35,
+ /**
+ * @property {Number} home
+ * @readonly
+ */
home:36,
+ /**
+ * @property {Number} left
+ * @readonly
+ */
left:37,
+ /**
+ * @property {Number} up
+ * @readonly
+ */
up:38,
+ /**
+ * @property {Number} right
+ * @readonly
+ */
right:39,
+ /**
+ * @property {Number} down
+ * @readonly
+ */
down:40,
+ /**
+ * @property {Number} select
+ * @readonly
+ */
select:41,
+ /**
+ * @property {Number} insert
+ * @readonly
+ */
insert:45,
+ /**
+ * @property {Number} Delete
+ * @readonly
+ */
Delete:46,
+ /**
+ * @property {Number} 0
+ * @readonly
+ */
0:48,
+ /**
+ * @property {Number} 1
+ * @readonly
+ */
1:49,
+ /**
+ * @property {Number} 2
+ * @readonly
+ */
2:50,
+ /**
+ * @property {Number} 3
+ * @readonly
+ */
3:51,
+ /**
+ * @property {Number} 4
+ * @readonly
+ */
4:52,
+ /**
+ * @property {Number} 5
+ * @readonly
+ */
5:53,
+ /**
+ * @property {Number} 6
+ * @readonly
+ */
6:54,
+ /**
+ * @property {Number} 7
+ * @readonly
+ */
7:55,
+ /**
+ * @property {Number} 8
+ * @readonly
+ */
8:56,
+ /**
+ * @property {Number} 9
+ * @readonly
+ */
9:57,
+ /**
+ * @property {Number} a
+ * @readonly
+ */
a:65,
+ /**
+ * @property {Number} b
+ * @readonly
+ */
b:66,
+ /**
+ * @property {Number} c
+ * @readonly
+ */
c:67,
+ /**
+ * @property {Number} d
+ * @readonly
+ */
d:68,
+ /**
+ * @property {Number} e
+ * @readonly
+ */
e:69,
+ /**
+ * @property {Number} f
+ * @readonly
+ */
f:70,
+ /**
+ * @property {Number} g
+ * @readonly
+ */
g:71,
+ /**
+ * @property {Number} h
+ * @readonly
+ */
h:72,
+ /**
+ * @property {Number} i
+ * @readonly
+ */
i:73,
+ /**
+ * @property {Number} j
+ * @readonly
+ */
j:74,
+ /**
+ * @property {Number} k
+ * @readonly
+ */
k:75,
+ /**
+ * @property {Number} l
+ * @readonly
+ */
l:76,
+ /**
+ * @property {Number} m
+ * @readonly
+ */
m:77,
+ /**
+ * @property {Number} n
+ * @readonly
+ */
n:78,
+ /**
+ * @property {Number} o
+ * @readonly
+ */
o:79,
+ /**
+ * @property {Number} p
+ * @readonly
+ */
p:80,
+ /**
+ * @property {Number} q
+ * @readonly
+ */
q:81,
+ /**
+ * @property {Number} r
+ * @readonly
+ */
r:82,
+ /**
+ * @property {Number} s
+ * @readonly
+ */
s:83,
+ /**
+ * @property {Number} t
+ * @readonly
+ */
t:84,
+ /**
+ * @property {Number} u
+ * @readonly
+ */
u:85,
+ /**
+ * @property {Number} v
+ * @readonly
+ */
v:86,
+ /**
+ * @property {Number} w
+ * @readonly
+ */
w:87,
+ /**
+ * @property {Number} x
+ * @readonly
+ */
x:88,
+ /**
+ * @property {Number} y
+ * @readonly
+ */
y:89,
+ /**
+ * @property {Number} z
+ * @readonly
+ */
z:90,
+ /**
+ * @property {Number} num0
+ * @readonly
+ */
num0:96,
+ /**
+ * @property {Number} num1
+ * @readonly
+ */
num1:97,
+ /**
+ * @property {Number} num2
+ * @readonly
+ */
num2:98,
+ /**
+ * @property {Number} num3
+ * @readonly
+ */
num3:99,
+ /**
+ * @property {Number} num4
+ * @readonly
num4:100,
+ /**
+ * @property {Number} num5
+ * @readonly
+ */
num5:101,
+ /**
+ * @property {Number} num6
+ * @readonly
+ */
num6:102,
+ /**
+ * @property {Number} num7
+ * @readonly
+ */
num7:103,
+ /**
+ * @property {Number} num8
+ * @readonly
+ */
num8:104,
+ /**
+ * @property {Number} num9
+ * @readonly
+ */
num9:105,
+ /**
+ * @property {Number} *
+ * @readonly
+ */
'*':106,
+ /**
+ * @property {Number} +
+ * @readonly
+ */
'+':107,
+ /**
+ * @property {Number} -
+ * @readonly
+ */
'-':109,
+ /**
+ * @property {Number} numdel
+ * @readonly
+ */
'numdel':110,
+ /**
+ * @property {Number} /
+ * @readonly
+ */
'/':111,
+ /**
+ * @property {Number} f1
+ * @readonly
+ */
f1:112, //f1-f12 dont work on ie
+ /**
+ * @property {Number} f2
+ * @readonly
+ */
f2:113,
+ /**
+ * @property {Number} f3
+ * @readonly
+ */
f3:114,
+ /**
+ * @property {Number} f4
+ * @readonly
+ */
f4:115,
+ /**
+ * @property {Number} f5
+ * @readonly
+ */
f5:116,
+ /**
+ * @property {Number} f6
+ * @readonly
+ */
f6:117,
+ /**
+ * @property {Number} f7
+ * @readonly
+ */
f7:118,
+ /**
+ * @property {Number} f8
+ * @readonly
+ */
f8:119,
+ /**
+ * @property {Number} f9
+ * @readonly
+ */
f9:120,
+ /**
+ * @property {Number} f10
+ * @readonly
+ */
f10:121,
+ /**
+ * @property {Number} f11
+ * @readonly
+ */
f11:122,
+ /**
+ * @property {Number} f12
+ * @readonly
+ */
f12:123,
+ /**
+ * @property {Number} numlock
+ * @readonly
+ */
numlock:144,
+ /**
+ * @property {Number} scrolllock
+ * @readonly
+ */
scrolllock:145,
+ /**
+ * @property {Number} ;
+ * @readonly
+ */
';':186,
+ /**
+ * @property {Number} semicolon
+ * @readonly
+ */
semicolon:186,
+ /**
+ * @property {Number} equal
+ * @readonly
+ */
equal:187,
+ /**
+ * @property {Number} =
+ * @readonly
+ */
'=':187,
+ /**
+ * @property {Number} ,
+ * @readonly
+ */
',':188,
+ /**
+ * @property {Number} comma
+ * @readonly
+ */
comma:188,
+ /**
+ * @property {Number} dash
+ * @readonly
+ */
dash:189,
+ /**
+ * @property {Number} .
+ * @readonly
+ */
'.':190,
+ /**
+ * @property {Number} period
+ * @readonly
+ */
period:190,
+ /**
+ * @property {Number} forwardslash
+ * @readonly
+ */
forwardslash:191,
+ /**
+ * @property {Number} grave
+ * @readonly
+ */
grave:192,
+ /**
+ * @property {Number} [
+ * @readonly
+ */
'[':219,
+ /**
+ * @property {Number} openbracket
+ * @readonly
+ */
openbracket:219,
+ /**
+ * @property {Number} backslash
+ * @readonly
+ */
backslash:220,
+ /**
+ * @property {Number} ]
+ * @readonly
+ */
']':221,
+ /**
+ * @property {Number} closebracket
+ * @readonly
+ */
closebracket:221,
+ /**
+ * @property {Number} quote
+ * @readonly
+ */
quote:222,
// gamepad controll
+ /**
+ * @property {Number} dpadLeft
+ * @readonly
+ */
dpadLeft:1000,
+ /**
+ * @property {Number} dpadRight
+ * @readonly
+ */
dpadRight:1001,
+ /**
+ * @property {Number} dpadUp
+ * @readonly
+ */
dpadUp:1003,
+ /**
+ * @property {Number} dpadDown
+ * @readonly
+ */
dpadDown:1004,
+ /**
+ * @property {Number} dpadCenter
+ * @readonly
+ */
dpadCenter:1005
};
+/**
+ * @module cc
+ */
+
/**
* Image Format:JPG
- * @constant
- * @type {Number}
+ * @property {Number} FMT_JPG
+ * @readonly
*/
cc.FMT_JPG = 0;
/**
* Image Format:PNG
- * @constant
- * @type {Number}
+ * @property {Number} FMT_PNG
+ * @readonly
*/
cc.FMT_PNG = 1;
/**
* Image Format:TIFF
- * @constant
- * @type {Number}
+ * @property {Number} FMT_TIFF
+ * @readonly
*/
cc.FMT_TIFF = 2;
/**
* Image Format:RAWDATA
- * @constant
- * @type {Number}
+ * @property {Number} FMT_RAWDATA
+ * @readonly
*/
cc.FMT_RAWDATA = 3;
/**
* Image Format:WEBP
- * @constant
- * @type {Number}
+ * @property {Number} FMT_WEBP
+ * @readonly
*/
cc.FMT_WEBP = 4;
/**
* Image Format:UNKNOWN
- * @constant
- * @type {Number}
+ * @property {Number} FMT_UNKNOWN
+ * @readonly
*/
cc.FMT_UNKNOWN = 5;
diff --git a/cocos2d/core/platform/CCConfig.js b/cocos2d/core/platform/CCConfig.js
index e06a5f4fad..e82d40309e 100644
--- a/cocos2d/core/platform/CCConfig.js
+++ b/cocos2d/core/platform/CCConfig.js
@@ -31,7 +31,7 @@
* @type {String}
* @name cc.ENGINE_VERSION
*/
-window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.9 Beta";
+window['CocosEngine'] = cc.ENGINE_VERSION = 'Cocos Creator v0.7';
/**
*
@@ -53,16 +53,17 @@ window["CocosEngine"] = cc.ENGINE_VERSION = "Cocos2d-JS v3.9 Beta";
* To enabled set it to 1. Disabled by default.
* To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
*
- * @constant
- * @type {Number}
+ *
+ * @property {Number} FIX_ARTIFACTS_BY_STRECHING_TEXEL
+ * @readonly
*/
cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0;
/**
* Position of the FPS (Default: 0,0 (bottom-left corner))
* To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
- * @constant
- * @type {Vec2}
+ * @property {Vec2} DIRECTOR_STATS_POSITION
+ * @readonly
*/
cc.DIRECTOR_STATS_POSITION = cc.p(0, 0);
@@ -75,8 +76,8 @@ cc.DIRECTOR_STATS_POSITION = cc.p(0, 0);
* Default value: 0.1f
* To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
*
- * @constant
- * @type {Number}
+ * @property {Number} DIRECTOR_FPS_INTERVAL
+ * @readonly
*/
cc.DIRECTOR_FPS_INTERVAL = 0.5;
@@ -88,8 +89,8 @@ cc.DIRECTOR_FPS_INTERVAL = 0.5;
* To enable set it to 1. Enabled by default.
* To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
*
- * @constant
- * @type {Number}
+ * @property {Number} COCOSNODE_RENDER_SUBPIXEL
+ * @readonly
*/
cc.COCOSNODE_RENDER_SUBPIXEL = 1;
@@ -101,8 +102,8 @@ cc.COCOSNODE_RENDER_SUBPIXEL = 1;
* To enable set it to 1. Enabled by default.
* To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
*
- * @constant
- * @type {Number}
+ * @property {Number} SPRITEBATCHNODE_RENDER_SUBPIXEL
+ * @readonly
*/
cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 1;
@@ -110,8 +111,8 @@ cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 1;
*
* Automatically premultiply alpha for PNG resources
*
- * @constant
- * @type {Number}
+ * @property {Number} AUTO_PREMULTIPLIED_ALPHA_FOR_PNG
+ * @readonly
*/
cc.AUTO_PREMULTIPLIED_ALPHA_FOR_PNG = 0;
@@ -123,8 +124,8 @@ cc.AUTO_PREMULTIPLIED_ALPHA_FOR_PNG = 0;
* To enable set it to a value different than 0. Enabled by default.
* To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
*
- * @constant
- * @type {Number}
+ * @property {Number} OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA
+ * @readonly
*/
cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0;
@@ -136,8 +137,8 @@ cc.OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA = 0;
* To enable set it to a value different than 0. Disabled by default.
* To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
*
- * @constant
- * @type {Number}
+ * @property {Number} TEXTURE_ATLAS_USE_TRIANGLE_STRIP
+ * @readonly
*/
cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0;
@@ -150,8 +151,8 @@ cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0;
* To disable it set it to 0. disable by default.(Not Supported on WebGL)
* To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
*
- * @constant
- * @type {Number}
+ * @property {Number} TEXTURE_ATLAS_USE_VAO
+ * @readonly
*/
cc.TEXTURE_ATLAS_USE_VAO = 0;
@@ -168,7 +169,7 @@ cc.TEXTURE_ATLAS_USE_VAO = 0;
* This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value.
* To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
*
- * @constant
+ * @readonly
* @type {Number}
* @deprecated This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it.
*/
@@ -185,7 +186,7 @@ cc.TEXTURE_NPOT_SUPPORT = 0;
* This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value.
* To modify it, in Web engine please refer to CCConfig.js, in JSB please refer to CCConfig.h
*
- * @constant
+ * @readonly
* @type {Number}
* @deprecated This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it.
*/
@@ -200,10 +201,10 @@ cc.RETINA_DISPLAY_SUPPORT = 1;
*
* Platforms: Only used on Retina Display devices like iPhone 4.
*
- * @constant
- * @type {String}
+ * @property {String} RETINA_DISPLAY_FILENAME_SUFFIX
+ * @readonly
*/
-cc.RETINA_DISPLAY_FILENAME_SUFFIX = "-hd";
+cc.RETINA_DISPLAY_FILENAME_SUFFIX = '-hd';
/**
*
@@ -213,8 +214,8 @@ cc.RETINA_DISPLAY_FILENAME_SUFFIX = "-hd";
*
* This feature is enabled by default.
*
- * @constant
- * @type {Number}
+ * @property {Number} USE_LA88_LABELS
+ * @readonly
*/
cc.USE_LA88_LABELS = 1;
@@ -228,8 +229,8 @@ cc.USE_LA88_LABELS = 1;
* 1 -- draw bounding box
* 2 -- draw texture box
*
- * @constant
- * @type {Number}
+ * @property {Number} SPRITE_DEBUG_DRAW
+ * @readonly
*/
cc.SPRITE_DEBUG_DRAW = 0;
@@ -240,8 +241,8 @@ cc.SPRITE_DEBUG_DRAW = 0;
*
* To enable set it to a value different than 0. Disabled by default.
*
- * @constant
- * @type {Number}
+ * @property {Number} SPRITEBATCHNODE_DEBUG_DRAW
+ * @readonly
*/
cc.SPRITEBATCHNODE_DEBUG_DRAW = 0;
@@ -252,8 +253,8 @@ cc.SPRITEBATCHNODE_DEBUG_DRAW = 0;
*
* To enable set it to a value different than 0. Disabled by default.
*
- * @constant
- * @type {Number}
+ * @property {Number} LABELBMFONT_DEBUG_DRAW
+ * @readonly
*/
cc.LABELBMFONT_DEBUG_DRAW = 0;
@@ -264,24 +265,24 @@ cc.LABELBMFONT_DEBUG_DRAW = 0;
*
* To enable set it to a value different than 0. Disabled by default.
*
- * @constant
- * @type {Number}
+ * @property {Number} LABELATLAS_DEBUG_DRAW
+ * @readonly
*/
cc.LABELATLAS_DEBUG_DRAW = 0;
/**
* Whether or not support retina display
- * @constant
- * @type {Number}
+ * @property {Number} IS_RETINA_DISPLAY_SUPPORTED
+ * @readonly
*/
cc.IS_RETINA_DISPLAY_SUPPORTED = 1;
/**
* Default engine
- * @constant
- * @type {String}
+ * @property {String} DEFAULT_ENGINE
+ * @readonly
*/
-cc.DEFAULT_ENGINE = cc.ENGINE_VERSION + "-canvas";
+cc.DEFAULT_ENGINE = cc.ENGINE_VERSION + '-canvas';
/**
*
@@ -289,8 +290,8 @@ cc.DEFAULT_ENGINE = cc.ENGINE_VERSION + "-canvas";
* 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.
*
- * @constant
- * @type {Number}
+ * @property {Number} ENABLE_STACKABLE_ACTIONS
+ * @readonly
*/
cc.ENABLE_STACKABLE_ACTIONS = 1;
@@ -306,7 +307,7 @@ cc.ENABLE_STACKABLE_ACTIONS = 1;
* It is recommend to enable whenever possible to improve speed.
* If you are migrating your code from GL ES 1.1, then keep it disabled. Once all your code works as expected, turn it on.
*
- * @constant
- * @type {Number}
+ * @property {Number} ENABLE_GL_STATE_CACHE
+ * @readonly
*/
cc.ENABLE_GL_STATE_CACHE = 1;
\ No newline at end of file
diff --git a/cocos2d/core/platform/CCEGLView.js b/cocos2d/core/platform/CCEGLView.js
index fc110e66ef..ae1fc7d443 100644
--- a/cocos2d/core/platform/CCEGLView.js
+++ b/cocos2d/core/platform/CCEGLView.js
@@ -1318,70 +1318,58 @@ cc.js.get(cc.ResolutionPolicy.prototype, "canvasSize", function () {
});
/**
- * @memberOf cc.ResolutionPolicy#
- * @name EXACT_FIT
- * @constant
- * @type {Number}
- * @static
* The entire application is visible in the specified area without trying to preserve the original aspect ratio.
* Distortion can occur, and the application may appear stretched or compressed.
+ * @property {Number} EXACT_FIT
+ * @readonly
+ * @static
*/
cc.ResolutionPolicy.EXACT_FIT = 0;
/**
- * @memberOf cc.ResolutionPolicy#
- * @name NO_BORDER
- * @constant
- * @type {Number}
- * @static
* The entire application fills the specified area, without distortion but possibly with some cropping,
* while maintaining the original aspect ratio of the application.
+ * @property {Number} NO_BORDER
+ * @readonly
+ * @static
*/
cc.ResolutionPolicy.NO_BORDER = 1;
/**
- * @memberOf cc.ResolutionPolicy#
- * @name SHOW_ALL
- * @constant
- * @type {Number}
- * @static
* The entire application is visible in the specified area without distortion while maintaining the original
* aspect ratio of the application. Borders can appear on two sides of the application.
+ * @property {Number} SHOW_ALL
+ * @readonly
+ * @static
*/
cc.ResolutionPolicy.SHOW_ALL = 2;
/**
- * @memberOf cc.ResolutionPolicy#
- * @name FIXED_HEIGHT
- * @constant
- * @type {Number}
- * @static
* The application takes the height of the design resolution size and modifies the width of the internal
* canvas so that it fits the aspect ratio of the device
* no distortion will occur however you must make sure your application works on different
* aspect ratios
+ * @property {Number} FIXED_HEIGHT
+ * @readonly
+ * @static
*/
cc.ResolutionPolicy.FIXED_HEIGHT = 3;
/**
- * @memberOf cc.ResolutionPolicy#
- * @name FIXED_WIDTH
- * @constant
- * @type {Number}
- * @static
* The application takes the width of the design resolution size and modifies the height of the internal
* canvas so that it fits the aspect ratio of the device
* no distortion will occur however you must make sure your application works on different
* aspect ratios
+ * @property {Number} FIXED_WIDTH
+ * @readonly
+ * @static
*/
cc.ResolutionPolicy.FIXED_WIDTH = 4;
/**
- * @memberOf cc.ResolutionPolicy#
- * @name UNKNOWN
- * @constant
- * @type {Number}
- * @static
* Unknow policy
+ * @property {Number} UNKNOWN
+ * @readonly
+ * @static
*/
cc.ResolutionPolicy.UNKNOWN = 5;
diff --git a/cocos2d/core/platform/CCLoader.js b/cocos2d/core/platform/CCLoader.js
index a53e5a054e..4f9d15a1a4 100644
--- a/cocos2d/core/platform/CCLoader.js
+++ b/cocos2d/core/platform/CCLoader.js
@@ -1,5 +1,3 @@
-'use strict';
-
var _noCacheRex = /\?/;
function urlAppendTimestamp (url) {
if (cc.game.config['noCache'] && typeof url === 'string') {
diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js
index 7ba86470da..c64457e7b7 100644
--- a/cocos2d/core/platform/CCMacro.js
+++ b/cocos2d/core/platform/CCMacro.js
@@ -25,46 +25,46 @@
****************************************************************************/
/**
- * @constant
- * @type {Number}
+ * @property {Number} INVALID_INDEX
+ * @readonly
*/
cc.INVALID_INDEX = -1;
/**
* PI is the ratio of a circle's circumference to its diameter.
- * @constant
- * @type {Number}
+ * @property {Number} PI
+ * @readonly
*/
cc.PI = Math.PI;
/**
- * @constant
- * @type {Number}
+ * @property {Number} FLT_MAX
+ * @readonly
*/
cc.FLT_MAX = parseFloat('3.402823466e+38F');
/**
- * @constant
- * @type {Number}
+ * @property {Number} FLT_MIN
+ * @readonly
*/
cc.FLT_MIN = parseFloat("1.175494351e-38F");
/**
- * @constant
- * @type {Number}
+ * @property {Number} RAD
+ * @readonly
*/
cc.RAD = cc.PI / 180;
/**
- * @constant
- * @type {Number}
+ * @property {Number} DEG
+ * @readonly
*/
cc.DEG = 180 / cc.PI;
/**
* maximum unsigned int value
- * @constant
- * @type {Number}
+ * @property {Number} UINT_MAX
+ * @readonly
*/
cc.UINT_MAX = 0xffffffff;
@@ -159,10 +159,10 @@ cc.radiansToDegress = function (angle) {
};
/**
- * @constant
- * @type Number
+ * @property {Number} REPEAT_FOREVER
+ * @readonly
*/
-cc.REPEAT_FOREVER = Number.MAX_VALUE - 1;
+cc.REPEAT_FOREVER = cc.sys.isNative ? 0xffffffff : (Number.MAX_VALUE - 1);
/**
* Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix
@@ -229,8 +229,8 @@ cc.incrementGLDraws = function (addNumber) {
};
/**
- * @constant
- * @type {Number}
+ * @property {Number} FLT_EPSILON
+ * @readonly
*/
cc.FLT_EPSILON = 0.0000001192092896;
@@ -334,95 +334,94 @@ cc.rectPointsToPixels = cc.IS_RETINA_DISPLAY_SUPPORTED ? function (point) {
//some gl constant variable
/**
- * @constant
- * @type {Number}
+ * @property {Number} ONE
+ * @readonly
*/
cc.ONE = 1;
/**
- * @constant
- * @type {Number}
+ * @property {Number} ZERO
+ * @readonly
*/
cc.ZERO = 0;
/**
- * @constant
- * @type {Number}
+ * @property {Number} SRC_ALPHA
+ * @readonly
*/
cc.SRC_ALPHA = 0x0302;
/**
- * @constant
- * @type {Number}
+ * @property {Number} SRC_ALPHA_SATURATE
+ * @readonly
*/
cc.SRC_ALPHA_SATURATE = 0x308;
/**
- * @constant
- * @type {Number}
+ * @property {Number} SRC_COLOR
+ * @readonly
*/
cc.SRC_COLOR = 0x300;
/**
- * @constant
- * @type {Number}
+ * @property {Number} DST_ALPHA
+ * @readonly
*/
cc.DST_ALPHA = 0x304;
/**
- * @constant
- * @type {Number}
+ * @property {Number} DST_COLOR
+ * @readonly
*/
cc.DST_COLOR = 0x306;
/**
- * @constant
- * @type {Number}
+ * @property {Number} ONE_MINUS_SRC_ALPHA
+ * @readonly
*/
cc.ONE_MINUS_SRC_ALPHA = 0x0303;
/**
- * @constant
- * @type {Number}
+ * @property {Number} ONE_MINUS_SRC_COLOR
+ * @readonly
*/
cc.ONE_MINUS_SRC_COLOR = 0x301;
/**
- * @constant
- * @type {Number}
+ * @property {Number} ONE_MINUS_DST_ALPHA
+ * @readonly
*/
cc.ONE_MINUS_DST_ALPHA = 0x305;
/**
- * @constant
- * @type {Number}
+ * @property {Number} ONE_MINUS_DST_COLOR
+ * @readonly
*/
cc.ONE_MINUS_DST_COLOR = 0x0307;
/**
- * @constant
- * @type {Number}
+ * @property {Number} ONE_MINUS_CONSTANT_ALPHA
+ * @readonly
*/
cc.ONE_MINUS_CONSTANT_ALPHA = 0x8004;
/**
- * @constant
- * @type {Number}
+ * @property {Number} ONE_MINUS_CONSTANT_COLOR
+ * @readonly
*/
cc.ONE_MINUS_CONSTANT_COLOR = 0x8002;
/**
* the constant variable equals gl.LINEAR for texture
- * @constant
- * @type {Number}
+ * @property {Number} LINEAR
+ * @readonly
*/
cc.LINEAR = 0x2601;
/**
* default gl blend src function. Compatible with premultiplied alpha images.
- * @constant
- * @name BLEND_SRC
- * @type {Number}
+ * @property {Number} BLEND_SRC
+ * @readonly
*/
cc.defineGetterSetter(cc, "BLEND_SRC", function (){
if (cc._renderType === cc.game.RENDER_TYPE_WEBGL
@@ -436,8 +435,8 @@ cc.defineGetterSetter(cc, "BLEND_SRC", function (){
/**
* default gl blend dst function. Compatible with premultiplied alpha images.
- * @constant
- * @type {Number}
+ * @property {Number} BLEND_DST
+ * @readonly
*/
cc.BLEND_DST = 0x0303;
@@ -457,286 +456,286 @@ cc.checkGLErrorDebug = function () {
//Possible device orientations
/**
* Device oriented vertically, home button on the bottom (UIDeviceOrientationPortrait)
- * @constant
- * @type {Number}
+ * @property {Number} DEVICE_ORIENTATION_PORTRAIT
+ * @readonly
*/
cc.DEVICE_ORIENTATION_PORTRAIT = 0;
/**
* Device oriented horizontally, home button on the right (UIDeviceOrientationLandscapeLeft)
- * @constant
- * @type {Number}
+ * @property {Number} DEVICE_ORIENTATION_LANDSCAPE_LEFT
+ * @readonly
*/
cc.DEVICE_ORIENTATION_LANDSCAPE_LEFT = 1;
/**
* Device oriented vertically, home button on the top (UIDeviceOrientationPortraitUpsideDown)
- * @constant
- * @type {Number}
+ * @property {Number} DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN
+ * @readonly
*/
cc.DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN = 2;
/**
* Device oriented horizontally, home button on the left (UIDeviceOrientationLandscapeRight)
- * @constant
- * @type {Number}
+ * @property {Number} DEVICE_ORIENTATION_LANDSCAPE_RIGHT
+ * @readonly
*/
cc.DEVICE_ORIENTATION_LANDSCAPE_RIGHT = 3;
/**
* In browsers, we only support 2 orientations by change window size.
- * @constant
- * @type {Number}
+ * @property {Number} DEVICE_MAX_ORIENTATIONS
+ * @readonly
*/
cc.DEVICE_MAX_ORIENTATIONS = 2;
// ------------------- vertex attrib flags -----------------------------
/**
- * @constant
- * @type {Number}
+ * @property {Number} VERTEX_ATTRIB_FLAG_NONE
+ * @readonly
*/
cc.VERTEX_ATTRIB_FLAG_NONE = 0;
/**
- * @constant
- * @type {Number}
+ * @property {Number} VERTEX_ATTRIB_FLAG_POSITION
+ * @readonly
*/
cc.VERTEX_ATTRIB_FLAG_POSITION = 1 << 0;
/**
- * @constant
- * @type {Number}
+ * @property {Number} VERTEX_ATTRIB_FLAG_COLOR
+ * @readonly
*/
cc.VERTEX_ATTRIB_FLAG_COLOR = 1 << 1;
/**
- * @constant
- * @type {Number}
+ * @property {Number} VERTEX_ATTRIB_FLAG_TEX_COORDS
+ * @readonly
*/
cc.VERTEX_ATTRIB_FLAG_TEX_COORDS = 1 << 2;
/**
- * @constant
- * @type {Number}
+ * @property {Number} VERTEX_ATTRIB_FLAG_POS_COLOR_TEX
+ * @readonly
*/
cc.VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = ( cc.VERTEX_ATTRIB_FLAG_POSITION | cc.VERTEX_ATTRIB_FLAG_COLOR | cc.VERTEX_ATTRIB_FLAG_TEX_COORDS );
/**
* GL server side states
- * @constant
- * @type {Number}
+ * @property {Number} GL_ALL
+ * @readonly
*/
cc.GL_ALL = 0;
//-------------Vertex Attributes-----------
/**
- * @constant
- * @type {Number}
+ * @property {Number} VERTEX_ATTRIB_POSITION
+ * @readonly
*/
cc.VERTEX_ATTRIB_POSITION = 0;
/**
- * @constant
- * @type {Number}
+ * @property {Number} VERTEX_ATTRIB_COLOR
+ * @readonly
*/
cc.VERTEX_ATTRIB_COLOR = 1;
/**
- * @constant
- * @type {Number}
+ * @property {Number} VERTEX_ATTRIB_TEX_COORDS
+ * @readonly
*/
cc.VERTEX_ATTRIB_TEX_COORDS = 2;
/**
- * @constant
- * @type {Number}
+ * @property {Number} VERTEX_ATTRIB_MAX
+ * @readonly
*/
cc.VERTEX_ATTRIB_MAX = 3;
//------------Uniforms------------------
/**
- * @constant
- * @type {Number}
+ * @property {Number} UNIFORM_PMATRIX
+ * @readonly
*/
cc.UNIFORM_PMATRIX = 0;
/**
- * @constant
- * @type {Number}
+ * @property {Number} UNIFORM_MVMATRIX
+ * @readonly
*/
cc.UNIFORM_MVMATRIX = 1;
/**
- * @constant
- * @type {Number}
+ * @property {Number} UNIFORM_MVPMATRIX
+ * @readonly
*/
cc.UNIFORM_MVPMATRIX = 2;
/**
- * @constant
- * @type {Number}
+ * @property {Number} UNIFORM_TIME
+ * @readonly
*/
cc.UNIFORM_TIME = 3;
/**
- * @constant
- * @type {Number}
+ * @property {Number} UNIFORM_SINTIME
+ * @readonly
*/
cc.UNIFORM_SINTIME = 4;
/**
- * @constant
- * @type {Number}
+ * @property {Number} UNIFORM_COSTIME
+ * @readonly
*/
cc.UNIFORM_COSTIME = 5;
/**
- * @constant
- * @type {Number}
+ * @property {Number} UNIFORM_RANDOM01
+ * @readonly
*/
cc.UNIFORM_RANDOM01 = 6;
/**
- * @constant
- * @type {Number}
+ * @property {Number} UNIFORM_SAMPLER
+ * @readonly
*/
cc.UNIFORM_SAMPLER = 7;
/**
- * @constant
- * @type {Number}
+ * @property {Number} UNIFORM_MAX
+ * @readonly
*/
cc.UNIFORM_MAX = 8;
//------------Shader Name---------------
/**
- * @constant
- * @type {String}
+ * @property {String} SHADER_POSITION_TEXTURECOLOR
+ * @readonly
*/
cc.SHADER_POSITION_TEXTURECOLOR = "ShaderPositionTextureColor";
/**
- * @constant
- * @type {String}
+ * @property {String} SHADER_POSITION_TEXTURECOLORALPHATEST
+ * @readonly
*/
cc.SHADER_POSITION_TEXTURECOLORALPHATEST = "ShaderPositionTextureColorAlphaTest";
/**
- * @constant
- * @type {String}
+ * @property {String} SHADER_POSITION_COLOR
+ * @readonly
*/
cc.SHADER_POSITION_COLOR = "ShaderPositionColor";
/**
- * @constant
- * @type {String}
+ * @property {String} SHADER_POSITION_TEXTURE
+ * @readonly
*/
cc.SHADER_POSITION_TEXTURE = "ShaderPositionTexture";
/**
- * @constant
- * @type {String}
+ * @property {String} SHADER_POSITION_TEXTURE_UCOLOR
+ * @readonly
*/
cc.SHADER_POSITION_TEXTURE_UCOLOR = "ShaderPositionTexture_uColor";
/**
- * @constant
- * @type {String}
+ * @property {String} SHADER_POSITION_TEXTUREA8COLOR
+ * @readonly
*/
cc.SHADER_POSITION_TEXTUREA8COLOR = "ShaderPositionTextureA8Color";
/**
- * @constant
- * @type {String}
+ * @property {String} SHADER_POSITION_UCOLOR
+ * @readonly
*/
cc.SHADER_POSITION_UCOLOR = "ShaderPosition_uColor";
/**
- * @constant
- * @type {String}
+ * @property {String} SHADER_POSITION_LENGTHTEXTURECOLOR
+ * @readonly
*/
cc.SHADER_POSITION_LENGTHTEXTURECOLOR = "ShaderPositionLengthTextureColor";
//------------uniform names----------------
/**
- * @constant
- * @type {String}
+ * @property {String} UNIFORM_PMATRIX_S
+ * @readonly
*/
cc.UNIFORM_PMATRIX_S = "CC_PMatrix";
/**
- * @constant
- * @type {String}
+ * @property {String} UNIFORM_MVMATRIX_S
+ * @readonly
*/
cc.UNIFORM_MVMATRIX_S = "CC_MVMatrix";
/**
- * @constant
- * @type {String}
+ * @property {String} UNIFORM_MVPMATRIX_S
+ * @readonly
*/
cc.UNIFORM_MVPMATRIX_S = "CC_MVPMatrix";
/**
- * @constant
- * @type {String}
+ * @property {String} UNIFORM_TIME_S
+ * @readonly
*/
cc.UNIFORM_TIME_S = "CC_Time";
/**
- * @constant
- * @type {String}
+ * @property {String} UNIFORM_SINTIME_S
+ * @readonly
*/
cc.UNIFORM_SINTIME_S = "CC_SinTime";
/**
- * @constant
- * @type {String}
+ * @property {String} UNIFORM_COSTIME_S
+ * @readonly
*/
cc.UNIFORM_COSTIME_S = "CC_CosTime";
/**
- * @constant
- * @type {String}
+ * @property {String} UNIFORM_RANDOM01_S
+ * @readonly
*/
cc.UNIFORM_RANDOM01_S = "CC_Random01";
/**
- * @constant
- * @type {String}
+ * @property {String} UNIFORM_SAMPLER_S
+ * @readonly
*/
cc.UNIFORM_SAMPLER_S = "CC_Texture0";
/**
- * @constant
- * @type {String}
+ * @property {String} UNIFORM_ALPHA_TEST_VALUE_S
+ * @readonly
*/
cc.UNIFORM_ALPHA_TEST_VALUE_S = "CC_alpha_value";
//------------Attribute names--------------
/**
- * @constant
- * @type {String}
+ * @property {String} ATTRIBUTE_NAME_COLOR
+ * @readonly
*/
cc.ATTRIBUTE_NAME_COLOR = "a_color";
/**
- * @constant
- * @type {String}
+ * @property {String} ATTRIBUTE_NAME_POSITION
+ * @readonly
*/
cc.ATTRIBUTE_NAME_POSITION = "a_position";
/**
- * @constant
- * @type {String}
+ * @property {String} ATTRIBUTE_NAME_TEX_COORD
+ * @readonly
*/
cc.ATTRIBUTE_NAME_TEX_COORD = "a_texCoord";
/**
* default size for font size
- * @constant
- * @type {Number}
+ * @property {Number} ITEM_SIZE
+ * @readonly
*/
cc.ITEM_SIZE = 32;
/**
* default tag for current item
- * @constant
- * @type {Number}
+ * @property {Number} CURRENT_ITEM
+ * @readonly
*/
cc.CURRENT_ITEM = 0xc0c05001;
/**
* default tag for zoom action tag
- * @constant
- * @type {Number}
+ * @property {Number} ZOOM_ACTION_TAG
+ * @readonly
*/
cc.ZOOM_ACTION_TAG = 0xc0c05002;
/**
* default tag for normal
- * @constant
- * @type {Number}
+ * @property {Number} NORMAL_TAG
+ * @readonly
*/
cc.NORMAL_TAG = 8801;
/**
* default selected tag
- * @constant
- * @type {Number}
+ * @property {Number} SELECTED_TAG
+ * @readonly
*/
cc.SELECTED_TAG = 8802;
/**
* default disabled tag
- * @constant
- * @type {Number}
+ * @property {Number} DISABLE_TAG
+ * @readonly
*/
cc.DISABLE_TAG = 8803;
diff --git a/cocos2d/core/platform/CCObject.js b/cocos2d/core/platform/CCObject.js
index 34e7ab3405..ffdf1cf244 100644
--- a/cocos2d/core/platform/CCObject.js
+++ b/cocos2d/core/platform/CCObject.js
@@ -15,18 +15,19 @@ var HideInEditor = 1 << 10;
var IsOnEnableCalled = 1 << 12;
var IsOnLoadCalled = 1 << 13;
-var IsOnStartCalled = 1 << 14;
+var IsOnLoadStarted = 1 << 14;
+var IsOnStartCalled = 1 << 15;
-var IsPositionLocked = 1 << 15;
var IsRotationLocked = 1 << 16;
var IsScaleLocked = 1 << 17;
var IsAnchorLocked = 1 << 18;
var IsSizeLocked = 1 << 19;
+var IsPositionLocked = 1 << 20;
var Hide = HideInGame | HideInEditor;
// should not clone or serialize these flags
var PersistentMask = ~(ToDestroy | Dirty | Destroying | DontDestroy |
- IsOnEnableCalled | IsOnLoadCalled | IsOnStartCalled
+ IsOnEnableCalled | IsOnLoadStarted | IsOnLoadCalled | IsOnStartCalled
/*RegisteredInEditor*/);
/**
@@ -38,16 +39,14 @@ var PersistentMask = ~(ToDestroy | Dirty | Destroying | DontDestroy |
*/
function CCObject () {
/**
- * @property _name
- * @type string
+ * @property {String} _name
* @default ""
* @private
*/
this._name = '';
/**
- * @property _objFlags
- * @type number
+ * @property {Number} _objFlags
* @default 0
* @private
*/
@@ -67,15 +66,13 @@ CCObject.Flags = {
/**
* The object will not be saved.
- * @property DontSave
- * @type {Number}
+ * @property {Number} DontSave
*/
DontSave: DontSave,
/**
* The object will not be saved when building a player.
- * @property EditorOnly
- * @type {Number}
+ * @property {Number} EditorOnly
*/
EditorOnly: EditorOnly,
@@ -97,8 +94,7 @@ CCObject.Flags = {
/**
* Hide in game and hierarchy.
* This flag is readonly, it can only be used as an argument of scene.addEntity() or Entity.createWithFlags()
- * @property HideInGame
- * @type {Number}
+ * @property {Number} HideInGame
*/
HideInGame: HideInGame,
@@ -106,16 +102,14 @@ CCObject.Flags = {
/**
* This flag is readonly, it can only be used as an argument of scene.addEntity() or Entity.createWithFlags()
- * @property HideInEditor
- * @type {Number}
+ * @property {Number} HideInEditor
*/
HideInEditor: HideInEditor,
/**
* Hide in game view, hierarchy, and scene view... etc.
* This flag is readonly, it can only be used as an argument of scene.addEntity() or Entity.createWithFlags()
- * @property Hide
- * @type {Number}
+ * @property {Number} Hide
*/
Hide: Hide,
@@ -125,6 +119,7 @@ CCObject.Flags = {
// FLAGS FOR COMPONENT
IsOnLoadCalled: IsOnLoadCalled,
+ IsOnLoadStarted: IsOnLoadStarted,
IsOnEnableCalled: IsOnEnableCalled,
IsOnStartCalled: IsOnStartCalled,
@@ -190,8 +185,7 @@ var prototype = CCObject.prototype;
/**
* The name of the object.
- * @property name
- * @type {String}
+ * @property {String} name
* @default ""
*/
JS.getset(prototype, 'name',
@@ -205,8 +199,7 @@ JS.getset(prototype, 'name',
/**
* Indicates whether the object is not yet destroyed
- * @property isValid
- * @type {Boolean}
+ * @property {Boolean} isValid
* @default true
* @readOnly
*/
diff --git a/cocos2d/core/platform/CCSys.js b/cocos2d/core/platform/CCSys.js
index 7acfe06413..677c59a7c4 100644
--- a/cocos2d/core/platform/CCSys.js
+++ b/cocos2d/core/platform/CCSys.js
@@ -10,301 +10,258 @@ var sys = cc.sys;
/**
* English language code
- * @property LANGUAGE_ENGLISH
- * @type {String}
+ * @property {String} LANGUAGE_ENGLISH
* @readOnly
*/
sys.LANGUAGE_ENGLISH = "en";
/**
* Chinese language code
- * @property LANGUAGE_CHINESE
- * @type {String}
+ * @property {String} LANGUAGE_CHINESE
* @readOnly
*/
sys.LANGUAGE_CHINESE = "zh";
/**
* French language code
- * @property LANGUAGE_FRENCH
- * @type {String}
+ * @property {String} LANGUAGE_FRENCH
* @readOnly
*/
sys.LANGUAGE_FRENCH = "fr";
/**
* Italian language code
- * @property LANGUAGE_ITALIAN
- * @type {String}
+ * @property {String} LANGUAGE_ITALIAN
* @readOnly
*/
sys.LANGUAGE_ITALIAN = "it";
/**
* German language code
- * @property LANGUAGE_GERMAN
- * @type {String}
+ * @property {String} LANGUAGE_GERMAN
* @readOnly
*/
sys.LANGUAGE_GERMAN = "de";
/**
* Spanish language code
- * @property LANGUAGE_SPANISH
- * @type {String}
+ * @property {String} LANGUAGE_SPANISH
* @readOnly
*/
sys.LANGUAGE_SPANISH = "es";
/**
* Spanish language code
- * @property LANGUAGE_DUTCH
- * @type {String}
+ * @property {String} LANGUAGE_DUTCH
* @readOnly
*/
sys.LANGUAGE_DUTCH = "du";
/**
* Russian language code
- * @property LANGUAGE_RUSSIAN
- * @type {String}
+ * @property {String} LANGUAGE_RUSSIAN
* @readOnly
*/
sys.LANGUAGE_RUSSIAN = "ru";
/**
* Korean language code
- * @property LANGUAGE_KOREAN
- * @type {String}
+ * @property {String} LANGUAGE_KOREAN
* @readOnly
*/
sys.LANGUAGE_KOREAN = "ko";
/**
* Japanese language code
- * @property LANGUAGE_JAPANESE
- * @type {String}
+ * @property {String} LANGUAGE_JAPANESE
* @readOnly
*/
sys.LANGUAGE_JAPANESE = "ja";
/**
* Hungarian language code
- * @property LANGUAGE_HUNGARIAN
- * @constant
- * @type {String}
- * @readOnly
+ * @property {String} LANGUAGE_HUNGARIAN
+ * @readonly
*/
sys.LANGUAGE_HUNGARIAN = "hu";
/**
* Portuguese language code
- * @property LANGUAGE_PORTUGUESE
- * @type {String}
+ * @property {String} LANGUAGE_PORTUGUESE
* @readOnly
*/
sys.LANGUAGE_PORTUGUESE = "pt";
/**
* Arabic language code
- * @property LANGUAGE_ARABIC
- * @type {String}
+ * @property {String} LANGUAGE_ARABIC
* @readOnly
*/
sys.LANGUAGE_ARABIC = "ar";
/**
* Norwegian language code
- * @property LANGUAGE_NORWEGIAN
- * @type {String}
+ * @property {String} LANGUAGE_NORWEGIAN
* @readOnly
*/
sys.LANGUAGE_NORWEGIAN = "no";
/**
* Polish language code
- * @property LANGUAGE_POLISH
- * @type {String}
+ * @property {String} LANGUAGE_POLISH
* @readOnly
*/
sys.LANGUAGE_POLISH = "pl";
/**
* Unknown language code
- * @property LANGUAGE_UNKNOWN
- * @type {String}
+ * @property {String} LANGUAGE_UNKNOWN
* @readOnly
*/
sys.LANGUAGE_UNKNOWN = "unkonwn";
/**
- * @property OS_IOS
- * @type {String}
+ * @property {String} OS_IOS
* @readOnly
*/
sys.OS_IOS = "iOS";
/**
- * @property OS_ANDROID
- * @type {String}
+ * @property {String} OS_ANDROID
* @readOnly
*/
sys.OS_ANDROID = "Android";
/**
- * @property OS_WINDOWS
- * @type {String}
+ * @property {String} OS_WINDOWS
* @readOnly
*/
sys.OS_WINDOWS = "Windows";
/**
- * @property OS_MARMALADE
- * @type {String}
+ * @property {String} OS_MARMALADE
* @readOnly
*/
sys.OS_MARMALADE = "Marmalade";
/**
- * @property OS_LINUX
- * @type {String}
+ * @property {String} OS_LINUX
* @readOnly
*/
sys.OS_LINUX = "Linux";
/**
- * @property OS_BADA
- * @type {String}
+ * @property {String} OS_BADA
* @readOnly
*/
sys.OS_BADA = "Bada";
/**
- * @property OS_BLACKBERRY
- * @type {String}
+ * @property {String} OS_BLACKBERRY
* @readOnly
*/
sys.OS_BLACKBERRY = "Blackberry";
/**
- * @property OS_OSX
- * @type {String}
+ * @property {String} OS_OSX
* @readOnly
*/
sys.OS_OSX = "OS X";
/**
- * @property OS_WP8
- * @type {String}
+ * @property {String} OS_WP8
* @readOnly
*/
sys.OS_WP8 = "WP8";
/**
- * @property OS_WINRT
- * @type {String}
+ * @property {String} OS_WINRT
* @readOnly
*/
sys.OS_WINRT = "WINRT";
/**
- * @property OS_UNKNOWN
- * @type {String}
+ * @property {String} OS_UNKNOWN
* @readOnly
*/
sys.OS_UNKNOWN = "Unknown";
/**
- * @property UNKNOWN
- * @type {Number}
+ * @property {Number} UNKNOWN
* @readOnly
* @default -1
*/
sys.UNKNOWN = -1;
/**
- * @property WIN32
- * @type {Number}
+ * @property {Number} WIN32
* @readOnly
* @default 0
*/
sys.WIN32 = 0;
/**
- * @property LINUX
- * @type {Number}
+ * @property {Number} LINUX
* @readOnly
* @default 1
*/
sys.LINUX = 1;
/**
- * @property MACOS
- * @type {Number}
+ * @property {Number} MACOS
* @readOnly
* @default 2
*/
sys.MACOS = 2;
/**
- * @property ANDROID
- * @type {Number}
+ * @property {Number} ANDROID
* @readOnly
* @default 3
*/
sys.ANDROID = 3;
/**
- * @property IOS
- * @type {Number}
+ * @property {Number} IOS
* @readOnly
* @default 4
*/
sys.IPHONE = 4;
/**
- * @property IPAD
- * @type {Number}
+ * @property {Number} IPAD
* @readOnly
* @default 5
*/
sys.IPAD = 5;
/**
- * @property BLACKBERRY
- * @type {Number}
+ * @property {Number} BLACKBERRY
* @readOnly
* @default 6
*/
sys.BLACKBERRY = 6;
/**
- * @property NACL
- * @type {Number}
+ * @property {Number} NACL
* @readOnly
* @default 7
*/
sys.NACL = 7;
/**
- * @property EMSCRIPTEN
- * @type {Number}
+ * @property {Number} EMSCRIPTEN
* @readOnly
* @default 8
*/
sys.EMSCRIPTEN = 8;
/**
- * @property TIZEN
- * @type {Number}
+ * @property {Number} TIZEN
* @readOnly
* @default 9
*/
sys.TIZEN = 9;
/**
- * @property WINRT
- * @type {Number}
+ * @property {Number} WINRT
* @readOnly
* @default 10
*/
sys.WINRT = 10;
/**
- * @property WP8
- * @type {Number}
+ * @property {Number} WP8
* @readOnly
* @default 11
*/
sys.WP8 = 11;
/**
- * @property MOBILE_BROWSER
- * @type {Number}
+ * @property {Number} MOBILE_BROWSER
* @readOnly
* @default 100
*/
sys.MOBILE_BROWSER = 100;
/**
- * @property DESKTOP_BROWSER
- * @type {Number}
+ * @property {Number} DESKTOP_BROWSER
* @readOnly
* @default 101
*/
@@ -312,53 +269,169 @@ sys.DESKTOP_BROWSER = 101;
/**
* Indicates whether executes in editor's window process (Electron's renderer context)
- * @property EDITOR_PAGE
- * @type {Number}
+ * @property {Number} EDITOR_PAGE
* @readOnly
* @default 102
*/
sys.EDITOR_PAGE = 102;
/**
* Indicates whether executes in editor's main process (Electron's browser context)
- * @property EDITOR_CORE
- * @type {Number}
+ * @property {Number} EDITOR_CORE
* @readOnly
* @default 103
*/
sys.EDITOR_CORE = 103;
+/**
+ * BROWSER_TYPE_WECHAT
+ * @property {String} BROWSER_TYPE_WECHAT
+ * @readOnly
+ * @default "wechat"
+ */
sys.BROWSER_TYPE_WECHAT = "wechat";
+/**
+ *
+ * @property {String} BROWSER_TYPE_ANDROID
+ * @readOnly
+ * @default "androidbrowser"
+ */
sys.BROWSER_TYPE_ANDROID = "androidbrowser";
+/**
+ *
+ * @property {String} BROWSER_TYPE_IE
+ * @readOnly
+ * @default "ie"
+ */
sys.BROWSER_TYPE_IE = "ie";
+/**
+ *
+ * @property {String} BROWSER_TYPE_QQ
+ * @readOnly
+ * @default "qqbrowser"
+ */
sys.BROWSER_TYPE_QQ = "qqbrowser";
+/**
+ *
+ * @property {String} BROWSER_TYPE_MOBILE_QQ
+ * @readOnly
+ * @default "mqqbrowser"
+ */
sys.BROWSER_TYPE_MOBILE_QQ = "mqqbrowser";
+/**
+ *
+ * @property {String} BROWSER_TYPE_UC
+ * @readOnly
+ * @default "ucbrowser"
+ */
sys.BROWSER_TYPE_UC = "ucbrowser";
+/**
+ *
+ * @property {String} BROWSER_TYPE_360
+ * @readOnly
+ * @default "360browser"
+ */
sys.BROWSER_TYPE_360 = "360browser";
+/**
+ *
+ * @property {String} BROWSER_TYPE_BAIDU_APP
+ * @readOnly
+ * @default "baiduboxapp"
+ */
sys.BROWSER_TYPE_BAIDU_APP = "baiduboxapp";
+/**
+ *
+ * @property {String} BROWSER_TYPE_BAIDU
+ * @readOnly
+ * @default "baidubrowser"
+ */
sys.BROWSER_TYPE_BAIDU = "baidubrowser";
+/**
+ *
+ * @property {String} BROWSER_TYPE_MAXTHON
+ * @readOnly
+ * @default "maxthon"
+ */
sys.BROWSER_TYPE_MAXTHON = "maxthon";
+/**
+ *
+ * @property {String} BROWSER_TYPE_OPERA
+ * @readOnly
+ * @default "opera"
+ */
sys.BROWSER_TYPE_OPERA = "opera";
+/**
+ *
+ * @property {String} BROWSER_TYPE_OUPENG
+ * @readOnly
+ * @default "oupeng"
+ */
sys.BROWSER_TYPE_OUPENG = "oupeng";
+/**
+ *
+ * @property {String} BROWSER_TYPE_MIUI
+ * @readOnly
+ * @default "miuibrowser"
+ */
sys.BROWSER_TYPE_MIUI = "miuibrowser";
+/**
+ *
+ * @property {String} BROWSER_TYPE_FIREFOX
+ * @readOnly
+ * @default "firefox"
+ */
sys.BROWSER_TYPE_FIREFOX = "firefox";
+/**
+ *
+ * @property {String} BROWSER_TYPE_SAFARI
+ * @readOnly
+ * @default "safari"
+ */
sys.BROWSER_TYPE_SAFARI = "safari";
+/**
+ *
+ * @property {String} BROWSER_TYPE_CHROME
+ * @readOnly
+ * @default "chrome"
+ */
sys.BROWSER_TYPE_CHROME = "chrome";
+/**
+ *
+ * @property {String} BROWSER_TYPE_LIEBAO
+ * @readOnly
+ * @default "liebao"
+ */
sys.BROWSER_TYPE_LIEBAO = "liebao";
+/**
+ *
+ * @property {String} BROWSER_TYPE_QZONE
+ * @readOnly
+ * @default "qzone"
+ */
sys.BROWSER_TYPE_QZONE = "qzone";
+/**
+ *
+ * @property {String} BROWSER_TYPE_SOUGOU
+ * @readOnly
+ * @default "sogou"
+ */
sys.BROWSER_TYPE_SOUGOU = "sogou";
+/**
+ *
+ * @property {String} BROWSER_TYPE_UNKNOWN
+ * @readOnly
+ * @default "unknown"
+ */
sys.BROWSER_TYPE_UNKNOWN = "unknown";
/**
* Is native ? This is set to be true in jsb auto.
- * @property isNative
- * @type {Boolean}
+ * @property {Boolean} isNative
*/
sys.isNative = false;
/**
* Is web browser ?
- * @property isBrowser
- * @type {Boolean}
+ * @property {Boolean} isBrowser
*/
sys.isBrowser = typeof window === 'object' && typeof document === 'object';
@@ -390,15 +463,13 @@ else {
else {
/**
* Indicate whether system is mobile system
- * @property isMobile
- * @type {Boolean}
+ * @property {Boolean} isMobile
*/
sys.isMobile = ua.indexOf('mobile') !== -1 || ua.indexOf('android') !== -1;
/**
* Indicate the running platform
- * @property platform
- * @type {Number}
+ * @property {Number} platform
*/
sys.platform = sys.isMobile ? sys.MOBILE_BROWSER : sys.DESKTOP_BROWSER;
}
@@ -409,8 +480,7 @@ else {
/**
* Indicate the current language of the running system
- * @property language
- * @type {String}
+ * @property {String} language
*/
sys.language = currLanguage;
@@ -427,15 +497,13 @@ else {
/**
* Indicate the running os name
- * @property os
- * @type {String}
+ * @property {String} os
*/
sys.os = osName;
/**
* Indicate the running browser type
- * @property browserType
- * @type {String}
+ * @property {String} browserType
*/
sys.browserType = sys.BROWSER_TYPE_UNKNOWN;
/* Determine the browser type */
@@ -463,8 +531,7 @@ else {
/**
* Indicate the running browser version
- * @property browserVersion
- * @type {Number}
+ * @property {Number} browserVersion
*/
sys.browserVersion = "";
/* Determine the browser version number */
@@ -482,8 +549,7 @@ else {
/**
* Indicate the real pixel resolution of the whole game window
- * @property windowPixelResolution
- * @type {Number}
+ * @property {Number} windowPixelResolution
*/
sys.windowPixelResolution = {
width: ratio * w,
@@ -546,8 +612,7 @@ else {
/**
* cc.sys.localStorage is a local storage component.
- * @property localStorage
- * @type {Object}
+ * @property {Object} localStorage
*/
try {
var localStorage = sys.localStorage = win.localStorage;
@@ -581,8 +646,7 @@ else {
/**
* The capabilities of the current platform
- * @property capabilities
- * @type {Object}
+ * @property {Object} capabilities
*/
var capabilities = sys.capabilities = {
"canvas": _supportCanvas,
diff --git a/cocos2d/core/platform/CCVisibleRect.js b/cocos2d/core/platform/CCVisibleRect.js
index 4cdc148980..08cec5fa16 100644
--- a/cocos2d/core/platform/CCVisibleRect.js
+++ b/cocos2d/core/platform/CCVisibleRect.js
@@ -45,6 +45,7 @@ cc.visibleRect = {
/**
* initialize
+ * @method init
* @param {Rect} visibleRect
*/
init:function(visibleRect){
@@ -88,67 +89,56 @@ cc.visibleRect = {
/**
* Top left coordinate of the screen related to the game scene.
- * @property topLeft
- * @type {Vec2}
+ * @property {Vec2} topLeft
*/
/**
* Top right coordinate of the screen related to the game scene.
- * @property topRight
- * @type {Vec2}
+ * @property {Vec2} topRight
*/
/**
* Top center coordinate of the screen related to the game scene.
- * @property top
- * @type {Vec2}
+ * @property {Vec2} top
*/
/**
* Bottom left coordinate of the screen related to the game scene.
- * @property bottomLeft
- * @type {Vec2}
+ * @property {Vec2} bottomLeft
*/
/**
* Bottom right coordinate of the screen related to the game scene.
- * @property bottomRight
- * @type {Vec2}
+ * @property {Vec2} bottomRight
*/
/**
* Bottom center coordinate of the screen related to the game scene.
- * @property bottom
- * @type {Vec2}
+ * @property {Vec2} bottom
*/
/**
* Center coordinate of the screen related to the game scene.
- * @property center
- * @type {Vec2}
+ * @property {Vec2} center
*/
/**
* Left center coordinate of the screen related to the game scene.
- * @property left
- * @type {Vec2}
+ * @property {Vec2} left
*/
/**
* Right center coordinate of the screen related to the game scene.
- * @property right
- * @type {Vec2}
+ * @property {Vec2} right
*/
/**
* Width of the screen.
- * @property width
- * @type {Number}
+ * @property {Number} width
*/
/**
* Height of the screen.
- * @property height
- * @type {Number}
+ * @property {Number} height
*/
diff --git a/cocos2d/core/platform/deserialize.js b/cocos2d/core/platform/deserialize.js
index 64dc720337..52848feb44 100644
--- a/cocos2d/core/platform/deserialize.js
+++ b/cocos2d/core/platform/deserialize.js
@@ -47,27 +47,23 @@ var Details = function () {
/**
* list of the depends assets' uuid
- * @property uuidList
- * @type {String[]}
+ * @property {String[]} uuidList
*/
this.uuidList = [];
/**
* the obj list whose field needs to load asset by uuid
- * @property uuidObjList
- * @type {Object[]}
+ * @property {Object[]} uuidObjList
*/
this.uuidObjList = [];
/**
* the corresponding field name which referenced to the asset
- * @property uuidPropList
- * @type {String[]}
+ * @property {String[]} uuidPropList
*/
this.uuidPropList = [];
/**
* the corresponding field name which referenced to the raw object
- * @property rawProp
- * @type {String}
+ * @property {String} rawProp
*/
this.rawProp = '';
@@ -500,6 +496,7 @@ var _Deserializer = (function () {
* @param {deserialize.Details} [result] - additional loading result
* @param {Object} [options]
* @return {object} the main data(asset)
+ * @module cc
*/
cc.deserialize = function (data, result, options) {
var classFinder = (options && options.classFinder) || JS._getClassById;
diff --git a/cocos2d/core/platform/load-manager.js b/cocos2d/core/platform/load-manager.js
index 16731e7de8..b6099fbe8f 100644
--- a/cocos2d/core/platform/load-manager.js
+++ b/cocos2d/core/platform/load-manager.js
@@ -63,16 +63,14 @@ var LoadManager = {
/**
* Max allowed concurrent request count
- * @property maxConcurrent
- * @type {Number}
+ * @property {Number} maxConcurrent
* @default 2
*/
maxConcurrent: 2,
/**
* Current concurrent request count
- * @property _curConcurrent
- * @type {Number}
+ * @property {Number} _curConcurrent
* @readOnly
*/
_curConcurrent: 0,
diff --git a/cocos2d/core/platform/preprocess-attrs.js b/cocos2d/core/platform/preprocess-attrs.js
index 3d8a0224d5..359779bf54 100644
--- a/cocos2d/core/platform/preprocess-attrs.js
+++ b/cocos2d/core/platform/preprocess-attrs.js
@@ -95,7 +95,7 @@ function checkUrl (val, className, propName, url) {
return cc.error('The "url" type of "%s.%s" must be child class of cc.RawAsset.', className, propName);
}
if (cc.isChildClassOf(url, cc.Asset)) {
- return cc.error('The "url" type of "%s.%s" must not be child class of cc.Asset,' +
+ return cc.error('The "url" type of "%s.%s" must not be child class of cc.Asset, ' +
'otherwise you should use "type: %s" instead.', className, propName, cc.js.getClassName(url));
}
if (val.type) {
@@ -145,10 +145,24 @@ function postCheckType (val, type, className, propName) {
}
}
-module.exports = function (properties, className) {
+function getBaseClassWherePropertyDefined (propName, cls) {
+ if (CC_DEV) {
+ var res;
+ for (; cls && cls.__props__ && cls.__props__.indexOf(propName) !== -1; cls = cls.$super) {
+ res = cls;
+ }
+ if (!res) {
+ cc.error('unknown error');
+ }
+ return res;
+ }
+}
+
+module.exports = function (properties, className, cls) {
for (var propName in properties) {
var val = properties[propName];
var isLiteral = val && val.constructor === Object;
+
if ( !isLiteral ) {
if (Array.isArray(val) && val.length > 0) {
val = {
@@ -179,6 +193,11 @@ module.exports = function (properties, className) {
properties[propName] = val;
}
if (val) {
+ if (!val.override && cls.__props__.indexOf(propName) !== -1 && CC_DEV) {
+ // check override
+ var baseClass = cc.js.getClassName(getBaseClassWherePropertyDefined(propName, cls));
+ cc.warn('"%s.%s" hides inherited property "%s.%s". To make the current property override that implementation, add the `override: true` attribute please.', className, propName, baseClass, propName);
+ }
var notify = val.notify;
if (notify) {
parseNotify(val, propName, notify, properties);
diff --git a/extensions/ccui/base-classes/UIScale9Sprite.js b/cocos2d/core/sprites/CCScale9Sprite.js
similarity index 95%
rename from extensions/ccui/base-classes/UIScale9Sprite.js
rename to cocos2d/core/sprites/CCScale9Sprite.js
index f5ab1275bf..44f2bef4b4 100644
--- a/extensions/ccui/base-classes/UIScale9Sprite.js
+++ b/cocos2d/core/sprites/CCScale9Sprite.js
@@ -50,7 +50,7 @@ EventTarget = require("../cocos2d/core/event/event-target");
* @property {Number} insetRight - The right inset of the 9-slice sprite
* @property {Number} insetBottom - The bottom inset of the 9-slice sprite
*/
-ccui.Scale9Sprite = cc.Scale9Sprite = _ccsg.Node.extend({
+cc.Scale9Sprite = _ccsg.Node.extend({
//resource data, could be async loaded.
_spriteFrame: null,
@@ -218,7 +218,7 @@ ccui.Scale9Sprite = cc.Scale9Sprite = _ccsg.Node.extend({
* @return @see `RenderingType`
*/
setRenderingType: function (type) {
- if (this._renderingType == type) return;
+ if (this._renderingType === type) return;
this._renderingType = type;
this._quadsDirty = true;
},
@@ -493,14 +493,14 @@ ccui.Scale9Sprite = cc.Scale9Sprite = _ccsg.Node.extend({
_createRenderCmd: function () {
if (cc._renderType === cc.game.RENDER_TYPE_CANVAS)
- return new ccui.Scale9Sprite.CanvasRenderCmd(this);
+ return new cc.Scale9Sprite.CanvasRenderCmd(this);
else
- return new ccui.Scale9Sprite.WebGLRenderCmd(this);
+ return new cc.Scale9Sprite.WebGLRenderCmd(this);
}
});
-var _p = ccui.Scale9Sprite.prototype;
+var _p = cc.Scale9Sprite.prototype;
cc.js.addon(_p, EventTarget.prototype);
// Extended properties
@@ -520,31 +520,31 @@ cc.defineGetterSetter(_p, "insetBottom", _p.getInsetBottom, _p.setInsetBottom);
_p = null;
-ccui.Scale9Sprite.create = function (file) {
+cc.Scale9Sprite.create = function (file) {
return new cc.Scale9Sprite(file);
};
/**
- * create a ccui.Scale9Sprite with Sprite frame.
- * @deprecated since v3.0, please use "new ccui.Scale9Sprite(spriteFrame, capInsets)" instead.
+ * create a cc.Scale9Sprite with Sprite frame.
+ * @deprecated since v3.0, please use "new cc.Scale9Sprite(spriteFrame, capInsets)" instead.
* @param {cc.SpriteFrame} spriteFrame
* @param {cc.Rect} capInsets
- * @returns {ccui.Scale9Sprite}
+ * @returns {cc.Scale9Sprite}
*/
-ccui.Scale9Sprite.createWithSpriteFrame = function (spriteFrame) {
+cc.Scale9Sprite.createWithSpriteFrame = function (spriteFrame) {
return new cc.Scale9Sprite(spriteFrame);
};
/**
- * create a ccui.Scale9Sprite with a Sprite frame name
- * @deprecated since v3.0, please use "new ccui.Scale9Sprite(spriteFrameName, capInsets)" instead.
+ * create a cc.Scale9Sprite with a Sprite frame name
+ * @deprecated since v3.0, please use "new cc.Scale9Sprite(spriteFrameName, capInsets)" instead.
* @param {string} spriteFrameName
* @param {cc.Rect} capInsets
* @returns {Scale9Sprite}
*/
-ccui.Scale9Sprite.createWithSpriteFrameName = function (spriteFrameName) {
+cc.Scale9Sprite.createWithSpriteFrameName = function (spriteFrameName) {
return new cc.Scale9Sprite(spriteFrameName);
};
-ccui.Scale9Sprite.state = {NORMAL: 0, GRAY: 1};
-ccui.Scale9Sprite.RenderingType = {SIMPLE: 0, SLICE: 1};
+cc.Scale9Sprite.state = {NORMAL: 0, GRAY: 1};
+cc.Scale9Sprite.RenderingType = {SIMPLE: 0, SLICE: 1};
diff --git a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCScale9SpriteCanvasRenderCmd.js
similarity index 94%
rename from extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js
rename to cocos2d/core/sprites/CCScale9SpriteCanvasRenderCmd.js
index 64a37500ef..65b0281fe7 100644
--- a/extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js
+++ b/cocos2d/core/sprites/CCScale9SpriteCanvasRenderCmd.js
@@ -23,15 +23,15 @@
****************************************************************************/
(function() {
- ccui.Scale9Sprite.CanvasRenderCmd = function (renderable) {
+ cc.Scale9Sprite.CanvasRenderCmd = function (renderable) {
_ccsg.Node.CanvasRenderCmd.call(this, renderable);
this._needDraw = true;
- this._state = ccui.Scale9Sprite.state.NORMAL;
+ this._state = cc.Scale9Sprite.state.NORMAL;
this._textureToRender = null;
};
- var proto = ccui.Scale9Sprite.CanvasRenderCmd.prototype = Object.create(_ccsg.Node.CanvasRenderCmd.prototype);
- proto.constructor = ccui.Scale9Sprite.CanvasRenderCmd;
+ var proto = cc.Scale9Sprite.CanvasRenderCmd.prototype = Object.create(_ccsg.Node.CanvasRenderCmd.prototype);
+ proto.constructor = cc.Scale9Sprite.CanvasRenderCmd;
proto._updateDisplayOpacity = function(parentOpacity){
_ccsg.Node.WebGLRenderCmd.prototype._updateDisplayOpacity.call(this, parentOpacity);
diff --git a/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js
similarity index 86%
rename from extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js
rename to cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js
index 5537a1f2c6..ba197f6440 100644
--- a/extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js
+++ b/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js
@@ -24,7 +24,7 @@
(function() {
if(!_ccsg.Node.WebGLRenderCmd)
return;
- ccui.Scale9Sprite.WebGLRenderCmd = function (renderable) {
+ cc.Scale9Sprite.WebGLRenderCmd = function (renderable) {
_ccsg.Node.WebGLRenderCmd.call(this, renderable);
this._needDraw = true;
this._cachedParent = null;
@@ -33,8 +33,8 @@
this._colorOpacityDirty = false;
};
- var proto = ccui.Scale9Sprite.WebGLRenderCmd.prototype = Object.create(_ccsg.Node.WebGLRenderCmd.prototype);
- proto.constructor = ccui.Scale9Sprite.WebGLRenderCmd;
+ var proto = cc.Scale9Sprite.WebGLRenderCmd.prototype = Object.create(_ccsg.Node.WebGLRenderCmd.prototype);
+ proto.constructor = cc.Scale9Sprite.WebGLRenderCmd;
proto.rendering = function (ctx){
var node = this._node;
@@ -111,32 +111,32 @@
proto.setState = function (state) {
var node = this._node;
- if (state === ccui.Scale9Sprite.state.NORMAL) {
+ if (state === cc.Scale9Sprite.state.NORMAL) {
node.setShaderProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR));
- } else if (state === ccui.Scale9Sprite.state.GRAY) {
- node.setShaderProgram(ccui.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram());
+ } else if (state === cc.Scale9Sprite.state.GRAY) {
+ node.setShaderProgram(cc.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram());
}
};
- ccui.Scale9Sprite.WebGLRenderCmd._grayShaderProgram = null;
- ccui.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram = function(){
- var grayShader = ccui.Scale9Sprite.WebGLRenderCmd._grayShaderProgram;
+ cc.Scale9Sprite.WebGLRenderCmd._grayShaderProgram = null;
+ cc.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram = function(){
+ var grayShader = cc.Scale9Sprite.WebGLRenderCmd._grayShaderProgram;
if(grayShader)
return grayShader;
grayShader = new cc.GLProgram();
- grayShader.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, ccui.Scale9Sprite.WebGLRenderCmd._grayShaderFragment);
+ grayShader.initWithVertexShaderByteArray(cc.SHADER_POSITION_TEXTURE_COLOR_VERT, cc.Scale9Sprite.WebGLRenderCmd._grayShaderFragment);
grayShader.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
grayShader.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
grayShader.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
grayShader.link();
grayShader.updateUniforms();
- ccui.Scale9Sprite.WebGLRenderCmd._grayShaderProgram = grayShader;
+ cc.Scale9Sprite.WebGLRenderCmd._grayShaderProgram = grayShader;
return grayShader;
};
- ccui.Scale9Sprite.WebGLRenderCmd._grayShaderFragment =
+ cc.Scale9Sprite.WebGLRenderCmd._grayShaderFragment =
"precision lowp float;\n"
+ "varying vec4 v_fragmentColor; \n"
+ "varying vec2 v_texCoord; \n"
diff --git a/cocos2d/core/utils/CCProfiler.js b/cocos2d/core/utils/CCProfiler.js
index 400c339509..db33a7d71e 100644
--- a/cocos2d/core/utils/CCProfiler.js
+++ b/cocos2d/core/utils/CCProfiler.js
@@ -20,9 +20,15 @@ cc.profiler = (function () {
else
fontSize = 0 | (w / 320 * 24);
- _FPSLabel = new cc.LabelTTF("000.0", "Arial", fontSize);
- _SPFLabel = new cc.LabelTTF("0.000", "Arial", fontSize);
- _drawsLabel = new cc.LabelTTF("0000", "Arial", fontSize);
+ _FPSLabel = new _ccsg.Label("000.0", "Arial");
+ _SPFLabel = new _ccsg.Label("0.000", "Arial");
+ _drawsLabel = new _ccsg.Label("0000", "Arial");
+ _FPSLabel.setFontSize(fontSize);
+ _SPFLabel.setFontSize(fontSize);
+ _drawsLabel.setFontSize(fontSize);
+ _FPSLabel.setContentSize(120, 40);
+ _SPFLabel.setContentSize(120, 40);
+ _drawsLabel.setContentSize(120, 40);
_drawsLabel.setPosition(_drawsLabel.width / 2 + locStatsPosition.x, _drawsLabel.height * 5 / 2 + locStatsPosition.y);
_SPFLabel.setPosition(_SPFLabel.width / 2 + locStatsPosition.x, _SPFLabel.height * 3 / 2 + locStatsPosition.y);
@@ -81,9 +87,9 @@ cc.profiler = (function () {
}
if (_showFPS) {
- _SPFLabel.string = _lastSPF.toFixed(3);
- _FPSLabel.string = _frameRate.toFixed(1);
- _drawsLabel.string = (0 | cc.g_NumberOfDraws).toString();
+ _SPFLabel.setString(_lastSPF.toFixed(3));
+ _FPSLabel.setString(_frameRate.toFixed(1));
+ _drawsLabel.setString((0 | cc.g_NumberOfDraws).toString());
}
}
@@ -131,15 +137,15 @@ cc.profiler = (function () {
},
showStats: function () {
- if (!_inited) {
- this.init();
- }
- if (cc.LabelTTF && !_FPSLabel) {
+ if (_ccsg.Label && !_FPSLabel) {
createStatsLabel();
}
if (_FPSLabel) {
_showFPS = true;
}
+ if (!_inited) {
+ this.init();
+ }
},
hideStats: function () {
diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js
index add75e7847..ae32acb75e 100644
--- a/cocos2d/core/utils/base-node.js
+++ b/cocos2d/core/utils/base-node.js
@@ -29,7 +29,7 @@ var DirtyFlags = require('./misc').DirtyFlags;
// called after changing parent
function setMaxZOrder (node) {
- var siblings = node._parent.getChildren();
+ var siblings = node.parent.getChildren();
var z = 0;
if (siblings.length >= 2) {
var prevNode = siblings[siblings.length - 2];
@@ -71,7 +71,6 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
// SERIALIZABLE
- _name: '',
_opacity: 255,
_color: cc.Color.WHITE,
_cascadeOpacityEnabled: true,
@@ -123,8 +122,8 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
return;
}
var node = this._sgNode;
- if (node._parent) {
- node._parent.removeChild(node, false);
+ if (node.parent) {
+ node.parent.removeChild(node, false);
}
if (value) {
var parent = value._sgNode;
@@ -172,7 +171,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
*/
uuid: {
get: function () {
- return this._id || (this._id = Editor.uuid());
+ return this._id || (this._id = window.Editor ? Editor.uuid() : '');
}
},
@@ -403,7 +402,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
},
set: function (value) {
if (this._anchorPoint.x !== value) {
- var old = this._anchorPoint.clone();
+ var old = cc.v2(this._anchorPoint);
this._anchorPoint.x = value;
this._onAnchorChanged();
this.emit(ANCHOR_CHANGED, old);
@@ -422,7 +421,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
},
set: function (value) {
if (this._anchorPoint.y !== value) {
- var old = this._anchorPoint.clone();
+ var old = cc.v2(this._anchorPoint);
this._anchorPoint.y = value;
this._onAnchorChanged();
this.emit(ANCHOR_CHANGED, old);
@@ -451,7 +450,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
if (this._sizeProvider) {
this._sizeProvider.setContentSize(value, this._sizeProvider._getHeight());
}
- var clone = this._contentSize.clone();
+ var clone = cc.size(this._contentSize);
this._contentSize.width = value;
this.emit(SIZE_CHANGED, clone);
}
@@ -479,7 +478,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
if (this._sizeProvider) {
this._sizeProvider.setContentSize(this._sizeProvider._getWidth(), value);
}
- var clone = this._contentSize.clone();
+ var clone = cc.size(this._contentSize);
this._contentSize.height = value;
this.emit(SIZE_CHANGED, clone);
}
@@ -576,7 +575,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
set: function (value) {
if ( !this._color.equals(value) ) {
var color = this._color;
- var old = color.clone();
+ var old = cc.color(color);
color.r = value.r;
color.g = value.g;
color.b = value.b;
@@ -753,17 +752,17 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
if (yValue === undefined) {
if(locPosition.x === newPosOrxValue.x && locPosition.y === newPosOrxValue.y)
return;
- oldPosition = locPosition.clone();
+ oldPosition = cc.v2(locPosition);
locPosition.x = newPosOrxValue.x;
locPosition.y = newPosOrxValue.y;
} else {
if(locPosition.x === newPosOrxValue && locPosition.y === yValue)
return;
- oldPosition = locPosition.clone();
+ oldPosition = cc.v2(locPosition);
locPosition.x = newPosOrxValue;
locPosition.y = yValue;
}
- this._sgNode.setPosition(newPosOrxValue, yValue);
+ this._sgNode.setPosition(locPosition);
if (this.emit) {
this.emit(POSITION_CHANGED, oldPosition);
@@ -804,13 +803,13 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
if (y === undefined) {
if ((point.x === locAnchorPoint.x) && (point.y === locAnchorPoint.y))
return;
- old = locAnchorPoint.clone();
+ old = cc.v2(locAnchorPoint);
locAnchorPoint.x = point.x;
locAnchorPoint.y = point.y;
} else {
if ((point === locAnchorPoint.x) && (y === locAnchorPoint.y))
return;
- old = locAnchorPoint.clone();
+ old = cc.v2(locAnchorPoint);
locAnchorPoint.x = point;
locAnchorPoint.y = y;
}
@@ -865,13 +864,13 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
if (height === undefined) {
if ((size.width === locContentSize.width) && (size.height === locContentSize.height))
return;
- clone = locContentSize.clone();
+ clone = cc.size(locContentSize);
locContentSize.width = size.width;
locContentSize.height = size.height;
} else {
if ((size === locContentSize.width) && (height === locContentSize.height))
return;
- clone = locContentSize.clone();
+ clone = cc.size(locContentSize);
locContentSize.width = size;
locContentSize.height = height;
}
@@ -888,7 +887,8 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
* @return {Rect} The calculated bounding box of the node
*/
getBoundingBox: function () {
- return this._sgNode.getBoundingBox();
+ var rect = cc.rect(0, 0, this._contentSize.width, this._contentSize.height);
+ return cc._rectApplyAffineTransformIn(rect, this.getNodeToParentTransform());
},
/**
@@ -1063,7 +1063,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
var children = this._children;
if (cleanup === undefined)
cleanup = true;
- for (var i = 0; i < children.length; i++) {
+ for (var i = children.length - 1; i >= 0; i--) {
var node = children[i];
if (node) {
//if (this._running) {
@@ -1187,7 +1187,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
* @return {Vec2}
*/
convertTouchToNodeSpace: function (touch) {
- return this.convertToNodeSpace(touch.getPosition());
+ return this.convertToNodeSpace(touch.getLocation());
},
/**
@@ -1197,7 +1197,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
* @return {Vec2}
*/
convertTouchToNodeSpaceAR: function (touch) {
- return this.convertToNodeSpaceAR(touch.getPosition());
+ return this.convertToNodeSpaceAR(touch.getLocation());
},
/**
@@ -1316,7 +1316,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
var sibling = siblings[i];
sibling._sgNode.arrivalOrder = i;
}
- cc.renderer.childrenOrderDirty = this._parent._sgNode._reorderChildDirty = true;
+ if (cc.renderer) {
+ cc.renderer.childrenOrderDirty = this._parent._sgNode._reorderChildDirty = true;
+ }
}
},
@@ -1404,7 +1406,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
// insert node
parentNode.addChild(sgNode);
sgNode.arrivalOrder = oldSgNode.arrivalOrder;
- cc.renderer.childrenOrderDirty = this._parent._sgNode._reorderChildDirty = true;
+ if (cc.renderer) {
+ cc.renderer.childrenOrderDirty = this._parent._sgNode._reorderChildDirty = true;
+ }
this._sgNode = sgNode;
diff --git a/cocos2d/core/value-types/CCEnum.js b/cocos2d/core/value-types/CCEnum.js
index 1c1e142c7d..746b43c359 100644
--- a/cocos2d/core/value-types/CCEnum.js
+++ b/cocos2d/core/value-types/CCEnum.js
@@ -28,7 +28,7 @@
/**
* Define an enum type. If a enum item has a value of -1, it will be given an Integer number according to it's order in the list. Otherwise it will use the value specified by user who writes the enum definition.
- * @method defineEnum
+ * @method Enum
* @param {object} obj - a JavaScript literal object containing enum names and values
* @return {object} the defined enum type
*
diff --git a/cocos2d/core/support/CCPointExtension.js b/cocos2d/core/value-types/CCPointExtension.js
similarity index 100%
rename from cocos2d/core/support/CCPointExtension.js
rename to cocos2d/core/value-types/CCPointExtension.js
diff --git a/cocos2d/core/value-types/index.js b/cocos2d/core/value-types/index.js
index d07dc54e5f..79f7664c66 100644
--- a/cocos2d/core/value-types/index.js
+++ b/cocos2d/core/value-types/index.js
@@ -1,6 +1,7 @@
require('./CCValueType');
require('./CCEnum');
require('./CCVec2');
+require('./CCPointExtension');
require('./CCSize');
require('./CCRect');
require('./CCColor');
diff --git a/cocos2d/deprecated.js b/cocos2d/deprecated.js
index abbbc190e6..8c70d0f2eb 100644
--- a/cocos2d/deprecated.js
+++ b/cocos2d/deprecated.js
@@ -231,11 +231,6 @@ if (CC_DEV) {
deprecateEnum(_ccsg.ParticleSystem, '_ccsg.ParticleSystem.MODE', '_ccsg.ParticleSystem.Mode');
deprecateEnum(cc.ParticleSystem, 'cc.ParticleSystem.TYPE', 'cc.ParticleSystem.PositionType');
deprecateEnum(cc.ParticleSystem, 'cc.ParticleSystem.MODE', 'cc.ParticleSystem.EmitterMode');
- deprecateEnum(ccui.ScrollView, 'ccui.ScrollView.DIR', 'ccui.ScrollView.Dir');
- deprecateEnum(ccui.ScrollView, 'ccui.ScrollView.EVENT', 'ccui.ScrollView.Event');
- deprecateEnum(ccui.Layout, 'ccui.Layout', 'ccui.Layout.Type', false);
- deprecateEnum(ccui.LoadingBar, 'ccui.LoadingBar.TYPE', 'ccui.LoadingBar.Type');
- deprecateEnum(ccui.RelativeLayoutParameter, 'ccui.RelativeLayoutParameter', 'ccui.RelativeLayoutParameter.Type', false);
deprecateEnum(cc.ProgressTimer, 'cc.ProgressTimer.TYPE', 'cc.ProgressTimer.Type');
deprecateEnum(cc.game, 'cc.game.DEBUG_MODE', 'cc.DebugMode');
if (cc.EditBox) {
diff --git a/cocos2d/labels/CCLabelBMFont.js b/cocos2d/labels/CCLabelBMFont.js
index 9ab4f2f828..d21ec4f8bd 100644
--- a/cocos2d/labels/CCLabelBMFont.js
+++ b/cocos2d/labels/CCLabelBMFont.js
@@ -30,8 +30,6 @@
http://www.angelcode.com/products/bmfont/ (Free, Windows only)
****************************************************************************/
-EventTarget = require("../cocos2d/core/event/event-target");
-
/**
* @constant
* @type Number
@@ -155,7 +153,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{
*/
ctor: function (str, fntFile, width, alignment, imageOffset) {
cc.SpriteBatchNode.prototype.ctor.call(this);
- EventTarget.call(this);
+ cc.EventTarget.call(this);
this._imageOffset = cc.p(0, 0);
this._reusedChar = [];
@@ -843,7 +841,7 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{
(function(){
var p = cc.LabelBMFont.prototype;
- cc.js.addon(p, EventTarget.prototype);
+ cc.js.addon(p, cc.EventTarget.prototype);
/** @expose */
p.string;
diff --git a/cocos2d/particle/CCParticleSystem.js b/cocos2d/particle/CCParticleSystem.js
index 9da59d4938..a28caa9c34 100644
--- a/cocos2d/particle/CCParticleSystem.js
+++ b/cocos2d/particle/CCParticleSystem.js
@@ -820,8 +820,8 @@ var ParticleSystem = cc.Class({
self.node.destroy();
};
}
- else {
- sgNode.onExit = null;
+ else if (sgNode.hasOwnProperty('onExit')) {
+ sgNode.onExit = _ccsg.Node.prototype.onExit;
}
}
}
diff --git a/editor/template/new-scene.fire b/editor/template/new-scene.fire
deleted file mode 100644
index f7787ac959..0000000000
--- a/editor/template/new-scene.fire
+++ /dev/null
@@ -1,37 +0,0 @@
-[
- {
- "__type__": "cc.SceneAsset",
- "scene": {
- "__id__": 1
- }
- },
- {
- "__type__": "cc.Scene",
- "_children": [
- {
- "__id__": 2
- }
- ]
- },
- {
- "__type__": "cc.Node",
- "_name": "Canvas",
- "_parent": {
- "__id__": 1
- },
- "_children": [],
- "_components": [
- {
- "__id__": 3
- }
- ]
- },
- {
- "__type__": "cc.Canvas",
- "node": {
- "__id__": 2
- },
- "_fitWidth": false,
- "_fitHeight": true
- }
-]
\ No newline at end of file
diff --git a/editor/template/new-script.coffee b/editor/template/new-script.coffee
deleted file mode 100644
index 0baab69e43..0000000000
--- a/editor/template/new-script.coffee
+++ /dev/null
@@ -1,16 +0,0 @@
-cc.Class {
- extends: cc.Component
-
- properties: {
- # foo:
- # default: null
- # type: cc
- # serializable: true # [optional], default is true
- # visible: true # [optional], default is true
- # displayName: 'Foo' # [optional], default is property name
- # readonly: false # [optional], default is false
- }
-
- update: (dt) ->
- # do your update here
-}
diff --git a/editor/template/new-script.js b/editor/template/new-script.js
deleted file mode 100644
index da1edcc6a0..0000000000
--- a/editor/template/new-script.js
+++ /dev/null
@@ -1,25 +0,0 @@
-cc.Class({
- extends: cc.Component,
-
- properties: {
- // foo: {
- // default: null,
- // url: cc.Texture2D, // optional, default is typeof default
- // serializable: true, // optional, default is true
- // visible: true, // optional, default is true
- // displayName: 'Foo', // optional
- // readonly: false, // optional, default is false
- // },
- // ...
- },
-
- // use this for initialization
- onLoad: function () {
-
- },
-
- // called every frame
- update: function (dt) {
-
- },
-});
diff --git a/gulp/tasks/build-cocos2d.js b/gulp/tasks/build-cocos2d.js
index e668f6cfa3..51cdbb6a48 100644
--- a/gulp/tasks/build-cocos2d.js
+++ b/gulp/tasks/build-cocos2d.js
@@ -1,251 +1,163 @@
+'use strict';
+
var Path = require('path');
var gulp = require('gulp');
-var rename = require('gulp-rename');
var concat = require('gulp-concat');
-var Spawn = require('child_process').spawn;
-var Chalk = require('chalk');
var es = require('event-stream');
var sourcemaps = require('gulp-sourcemaps');
var srcs = [
- "./Base64Images.js",
- "./CCBoot.js",
+ './Base64Images.js',
+ './CCBoot.js',
- "./cocos2d/core/platform/CCCommon.js",
- "./cocos2d/core/platform/CCSAXParser.js",
- "./cocos2d/core/platform/CCLoaders.js",
- "./cocos2d/core/platform/CCConfig.js",
- "./cocos2d/core/platform/miniFramework.js",
- "./cocos2d/core/platform/CCEGLView.js",
- "./cocos2d/core/platform/CCScreen.js",
- "./cocos2d/core/platform/CCVisibleRect.js",
+ './cocos2d/core/platform/CCCommon.js',
+ './cocos2d/core/platform/CCSAXParser.js',
+ './cocos2d/core/platform/CCLoaders.js',
+ './cocos2d/core/platform/CCConfig.js',
+ './cocos2d/core/platform/miniFramework.js',
+ './cocos2d/core/platform/CCEGLView.js',
+ './cocos2d/core/platform/CCScreen.js',
+ './cocos2d/core/platform/CCVisibleRect.js',
- "./cocos2d/core/support/CCPointExtension.js",
- "./cocos2d/core/support/CCVertex.js",
- "./cocos2d/core/support/TransformUtils.js",
+ './cocos2d/core/support/CCVertex.js',
+ './cocos2d/core/support/TransformUtils.js',
- "./cocos2d/core/event-manager/CCTouch.js",
- "./cocos2d/core/event-manager/CCSystemEvent.js",
- "./cocos2d/core/event-manager/CCEventListener.js",
- "./cocos2d/core/event-manager/CCEventManager.js",
+ './cocos2d/core/event-manager/CCTouch.js',
+ './cocos2d/core/event-manager/CCSystemEvent.js',
+ './cocos2d/core/event-manager/CCEventListener.js',
+ './cocos2d/core/event-manager/CCEventManager.js',
- "./cocos2d/core/renderer/RendererCanvas.js",
- "./cocos2d/core/renderer/RendererWebGL.js",
+ './cocos2d/core/renderer/RendererCanvas.js',
+ './cocos2d/core/renderer/RendererWebGL.js',
- "./cocos2d/core/base-nodes/BaseNodesPropertyDefine.js",
- "./cocos2d/core/base-nodes/CCSGNode.js",
- "./cocos2d/core/base-nodes/CCSGNodeCanvasRenderCmd.js",
- "./cocos2d/core/base-nodes/CCSGNodeWebGLRenderCmd.js",
+ './cocos2d/core/base-nodes/BaseNodesPropertyDefine.js',
+ './cocos2d/core/base-nodes/CCSGNode.js',
+ './cocos2d/core/base-nodes/CCSGNodeCanvasRenderCmd.js',
+ './cocos2d/core/base-nodes/CCSGNodeWebGLRenderCmd.js',
- "./extensions/ccui/base-classes/CCProtectedNode.js",
- "./extensions/ccui/base-classes/CCProtectedNodeCanvasRenderCmd.js",
- "./extensions/ccui/base-classes/CCProtectedNodeWebGLRenderCmd.js",
+ './cocos2d/core/scenes/CCSGScene.js',
+ './cocos2d/core/scenes/CCLoaderScene.js',
- "./cocos2d/core/base-nodes/CCAtlasNode.js",
- "./cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js",
- "./cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js",
+ './cocos2d/core/layers/CCLayer.js',
+ './cocos2d/core/layers/CCLayerCanvasRenderCmd.js',
+ './cocos2d/core/layers/CCLayerWebGLRenderCmd.js',
- "./cocos2d/core/scenes/CCSGScene.js",
- "./cocos2d/core/scenes/CCLoaderScene.js",
+ './cocos2d/core/sprites/SpritesPropertyDefine.js',
+ './cocos2d/core/sprites/CCSGSprite.js',
+ './cocos2d/core/sprites/CCSGSpriteCanvasRenderCmd.js',
+ './cocos2d/core/sprites/CCSGSpriteWebGLRenderCmd.js',
+ './cocos2d/core/sprites/CCBakeSprite.js',
+ './cocos2d/core/sprites/CCAnimation.js',
+ './cocos2d/core/sprites/CCAnimationCache.js',
+ './cocos2d/core/sprites/CCSpriteFrameCache.js',
+ './cocos2d/core/sprites/CCSpriteBatchNode.js',
+ './cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js',
+ './cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js',
- "./cocos2d/core/layers/CCLayer.js",
- "./cocos2d/core/layers/CCLayerCanvasRenderCmd.js",
- "./cocos2d/core/layers/CCLayerWebGLRenderCmd.js",
+ './cocos2d/core/sprites/CCScale9Sprite.js',
+ './cocos2d/core/sprites/CCScale9SpriteCanvasRenderCmd.js',
+ './cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js',
- "./cocos2d/core/sprites/SpritesPropertyDefine.js",
- "./cocos2d/core/sprites/CCSGSprite.js",
- "./cocos2d/core/sprites/CCSGSpriteCanvasRenderCmd.js",
- "./cocos2d/core/sprites/CCSGSpriteWebGLRenderCmd.js",
- "./cocos2d/core/sprites/CCBakeSprite.js",
- "./cocos2d/core/sprites/CCAnimation.js",
- "./cocos2d/core/sprites/CCAnimationCache.js",
- "./cocos2d/core/sprites/CCSpriteFrameCache.js",
- "./cocos2d/core/sprites/CCSpriteBatchNode.js",
- "./cocos2d/core/sprites/CCSpriteBatchNodeCanvasRenderCmd.js",
- "./cocos2d/core/sprites/CCSpriteBatchNodeWebGLRenderCmd.js",
+ './cocos2d/core/CCConfiguration.js',
+ './cocos2d/core/CCCamera.js',
+ './cocos2d/core/CCScheduler.js',
- "./cocos2d/core/CCConfiguration.js",
- "./cocos2d/core/CCCamera.js",
- "./cocos2d/core/CCScheduler.js",
+ './cocos2d/core/CCDrawingPrimitivesCanvas.js',
+ './cocos2d/core/CCDrawingPrimitivesWebGL.js',
- "./cocos2d/core/CCDrawingPrimitivesCanvas.js",
- "./cocos2d/core/CCDrawingPrimitivesWebGL.js",
+ './cocos2d/core/label/FNTLoader.js',
+ './cocos2d/core/label/CCSGLabel.js',
+ './cocos2d/core/label/CCSGLabelCanvasRenderCmd.js',
+ './cocos2d/core/label/CCSGLabelWebGLRenderCmd.js',
- "./cocos2d/core/labelttf/LabelTTFPropertyDefine.js",
- "./cocos2d/core/labelttf/CCLabelTTF.js",
- "./cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js",
- "./cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js",
+ './cocos2d/kazmath/utility.js',
+ './cocos2d/kazmath/vec2.js',
+ './cocos2d/kazmath/vec3.js',
+ './cocos2d/kazmath/vec4.js',
+ './cocos2d/kazmath/ray2.js',
+ './cocos2d/kazmath/mat3.js',
+ './cocos2d/kazmath/mat4.js',
+ './cocos2d/kazmath/plane.js',
+ './cocos2d/kazmath/quaternion.js',
+ './cocos2d/kazmath/aabb.js',
+ './cocos2d/kazmath/gl/mat4stack.js',
+ './cocos2d/kazmath/gl/matrix.js',
- "./cocos2d/core/CCActionManager.js",
+ './cocos2d/shaders/CCShaders.js',
+ './cocos2d/shaders/CCShaderCache.js',
+ './cocos2d/shaders/CCGLProgram.js',
+ './cocos2d/shaders/CCGLStateCache.js',
- "./cocos2d/kazmath/utility.js",
- "./cocos2d/kazmath/vec2.js",
- "./cocos2d/kazmath/vec3.js",
- "./cocos2d/kazmath/vec4.js",
- "./cocos2d/kazmath/ray2.js",
- "./cocos2d/kazmath/mat3.js",
- "./cocos2d/kazmath/mat4.js",
- "./cocos2d/kazmath/plane.js",
- "./cocos2d/kazmath/quaternion.js",
- "./cocos2d/kazmath/aabb.js",
- "./cocos2d/kazmath/gl/mat4stack.js",
- "./cocos2d/kazmath/gl/matrix.js",
+ './cocos2d/render-texture/CCRenderTexture.js',
+ './cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js',
+ './cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js',
- "./cocos2d/shaders/CCShaders.js",
- "./cocos2d/shaders/CCShaderCache.js",
- "./cocos2d/shaders/CCGLProgram.js",
- "./cocos2d/shaders/CCGLStateCache.js",
+ './cocos2d/shape-nodes/CCDrawNode.js',
+ './cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js',
+ './cocos2d/shape-nodes/CCDrawNodeWebGLRenderCmd.js',
- "./cocos2d/render-texture/CCRenderTexture.js",
- "./cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js",
- "./cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js",
+ './cocos2d/clipping-nodes/CCClippingNode.js',
+ './cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js',
+ './cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js',
- "./cocos2d/labels/CCSGLabel.js",
- "./cocos2d/labels/CCLabelAtlas.js",
- "./cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js",
- "./cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js",
- "./cocos2d/labels/CCLabelBMFont.js",
- "./cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js",
- "./cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js",
- "./cocos2d/labels/CCSGLabelCanvasRenderCmd.js",
- "./cocos2d/labels/CCSGLabelWebGLRenderCmd.js",
- "./cocos2d/shape-nodes/CCDrawNode.js",
- "./cocos2d/shape-nodes/CCDrawNodeCanvasRenderCmd.js",
- "./cocos2d/shape-nodes/CCDrawNodeWebGLRenderCmd.js",
+ './cocos2d/core/CCActionManager.js',
+ './cocos2d/actions/CCAction.js',
+ './cocos2d/actions/CCActionInterval.js',
+ './cocos2d/actions/CCActionInstant.js',
+ './cocos2d/actions/CCActionEase.js',
+ './cocos2d/actions/CCActionCatmullRom.js',
- "./cocos2d/clipping-nodes/CCClippingNode.js",
- "./cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js",
- "./cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js",
+ './cocos2d/progress-timer/CCProgressTimer.js',
+ './cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js',
+ './cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js',
+ './cocos2d/progress-timer/CCActionProgressTimer.js',
- "./cocos2d/actions/CCAction.js",
- "./cocos2d/actions/CCActionInterval.js",
- "./cocos2d/actions/CCActionInstant.js",
- "./cocos2d/actions/CCActionEase.js",
- "./cocos2d/actions/CCActionCatmullRom.js",
- "./cocos2d/actions/CCActionTween.js",
+ './cocos2d/compression/ZipUtils.js',
+ './cocos2d/compression/base64.js',
+ './cocos2d/compression/gzip.js',
+ './cocos2d/compression/zlib.min.js',
- "./cocos2d/progress-timer/CCProgressTimer.js",
- "./cocos2d/progress-timer/CCProgressTimerCanvasRenderCmd.js",
- "./cocos2d/progress-timer/CCProgressTimerWebGLRenderCmd.js",
- "./cocos2d/progress-timer/CCActionProgressTimer.js",
+ './cocos2d/particle/CCPNGReader.js',
+ './cocos2d/particle/CCTIFFReader.js',
+ './cocos2d/particle/CCSGParticleSystem.js',
+ './cocos2d/particle/CCSGParticleSystemCanvasRenderCmd.js',
+ './cocos2d/particle/CCSGParticleSystemWebGLRenderCmd.js',
+ './cocos2d/particle/CCSGParticleExamples.js',
+ './cocos2d/particle/CCParticleBatchNode.js',
+ './cocos2d/particle/CCParticleBatchNodeCanvasRenderCmd.js',
+ './cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js',
- "./cocos2d/compression/ZipUtils.js",
- "./cocos2d/compression/base64.js",
- "./cocos2d/compression/gzip.js",
- "./cocos2d/compression/zlib.min.js",
+ './cocos2d/menus/CCMenuItem.js',
+ './cocos2d/menus/CCMenu.js',
- "./cocos2d/particle/CCPNGReader.js",
- "./cocos2d/particle/CCTIFFReader.js",
- "./cocos2d/particle/CCSGParticleSystem.js",
- "./cocos2d/particle/CCSGParticleSystemCanvasRenderCmd.js",
- "./cocos2d/particle/CCSGParticleSystemWebGLRenderCmd.js",
- "./cocos2d/particle/CCSGParticleExamples.js",
- "./cocos2d/particle/CCParticleBatchNode.js",
- "./cocos2d/particle/CCParticleBatchNodeCanvasRenderCmd.js",
- "./cocos2d/particle/CCParticleBatchNodeWebGLRenderCmd.js",
+ './cocos2d/tilemap/CCTGAlib.js',
+ './cocos2d/tilemap/CCTMXTiledMap.js',
+ './cocos2d/tilemap/CCTMXXMLParser.js',
+ './cocos2d/tilemap/CCTMXObjectGroup.js',
+ './cocos2d/tilemap/CCTMXLayer.js',
+ './cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js',
+ './cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js',
- "./cocos2d/text-input/CCIMEDispatcher.js",
- "./cocos2d/text-input/CCTextFieldTTF.js",
+ './cocos2d/parallax/CCParallaxNode.js',
+ './cocos2d/parallax/CCParallaxNodeRenderCmd.js',
- "./cocos2d/menus/CCMenuItem.js",
- "./cocos2d/menus/CCMenu.js",
+ './cocos2d/audio/CCAudio.js',
- "./cocos2d/tilemap/CCTGAlib.js",
- "./cocos2d/tilemap/CCTMXTiledMap.js",
- "./cocos2d/tilemap/CCTMXXMLParser.js",
- "./cocos2d/tilemap/CCTMXObjectGroup.js",
- "./cocos2d/tilemap/CCTMXLayer.js",
- "./cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js",
- "./cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js",
+ './extensions/spine/Spine.js',
+ './extensions/spine/CCSkeleton.js',
+ './extensions/spine/CCSkeletonCanvasRenderCmd.js',
+ './extensions/spine/CCSkeletonWebGLRenderCmd.js',
+ './extensions/spine/CCSkeletonAnimation.js',
- "./cocos2d/parallax/CCParallaxNode.js",
- "./cocos2d/parallax/CCParallaxNodeRenderCmd.js",
+ './extensions/ccpool/CCPool.js',
- "./cocos2d/audio/CCAudio.js",
+ './cocos2d/physics/CCPhysicsDebugNode.js',
+ './cocos2d/physics/CCPhysicsDebugNodeCanvasRenderCmd.js',
+ './cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js',
- "./extensions/ccui/system/CocosGUI.js",
- "./extensions/ccui/base-classes/UIWidget.js",
- "./extensions/ccui/base-classes/UIWidgetRenderCmd.js",
- "./extensions/ccui/base-classes/UIScale9Sprite.js",
- "./extensions/ccui/base-classes/UIScale9SpriteCanvasRenderCmd.js",
- "./extensions/ccui/base-classes/UIScale9SpriteWebGLRenderCmd.js",
- "./extensions/ccui/layouts/UILayout.js",
- "./extensions/ccui/layouts/UILayoutCanvasRenderCmd.js",
- "./extensions/ccui/layouts/UILayoutWebGLRenderCmd.js",
- "./extensions/ccui/layouts/UILayoutParameter.js",
- "./extensions/ccui/layouts/UILayoutManager.js",
- "./extensions/ccui/layouts/UIHBox.js",
- "./extensions/ccui/layouts/UIVBox.js",
- "./extensions/ccui/layouts/UIRelativeBox.js",
- "./extensions/ccui/system/UIHelper.js",
- "./extensions/ccui/uiwidgets/UIButton.js",
- "./extensions/ccui/uiwidgets/UICheckBox.js",
- "./extensions/ccui/uiwidgets/UIImageView.js",
- "./extensions/ccui/uiwidgets/UILoadingBar.js",
- "./extensions/ccui/uiwidgets/UISlider.js",
- "./extensions/ccui/uiwidgets/UIText.js",
- "./extensions/ccui/uiwidgets/UITextAtlas.js",
- "./extensions/ccui/uiwidgets/UITextBMFont.js",
- "./extensions/ccui/uiwidgets/UITextField.js",
- "./extensions/ccui/uiwidgets/UIWebView.js",
- "./extensions/ccui/uiwidgets/UIVideoPlayer.js",
- "./extensions/ccui/uiwidgets/UIRichText.js",
- "./extensions/ccui/uiwidgets/scroll-widget/UIScrollView.js",
- "./extensions/ccui/uiwidgets/scroll-widget/UIListView.js",
- "./extensions/ccui/uiwidgets/scroll-widget/UIPageView.js",
- "./extensions/ccui/uiwidgets/scroll-widget/UIScrollViewCanvasRenderCmd.js",
- "./extensions/ccui/uiwidgets/scroll-widget/UIScrollViewWebGLRenderCmd.js",
- "./extensions/cocostudio/components/CCComponent.js",
- "./extensions/ccui/layouts/UILayoutComponent.js",
- "./extensions/cocostudio/components/CCComponentContainer.js",
-
- "./extensions/spine/Spine.js",
- "./extensions/spine/CCSkeleton.js",
- "./extensions/spine/CCSkeletonCanvasRenderCmd.js",
- "./extensions/spine/CCSkeletonWebGLRenderCmd.js",
- "./extensions/spine/CCSkeletonAnimation.js",
-
- "./extensions/ccpool/CCPool.js",
-
- "./cocos2d/physics/CCPhysicsDebugNode.js",
- "./cocos2d/physics/CCPhysicsDebugNodeCanvasRenderCmd.js",
- "./cocos2d/physics/CCPhysicsDebugNodeWebGLRenderCmd.js",
-
- "./external/chipmunk/chipmunk.js"
+ './external/chipmunk/chipmunk.js'
];
-gulp.task('compile-cocos2d', function (done) {
- console.log('Spawn ant in ' + paths.originCocos2dCompileDir);
-
- var spawn = require('child_process').spawn;
- var cmdStr = process.platform === 'win32' ? 'ant.bat' : 'ant';
- var child = Spawn(cmdStr, {
- cwd: paths.originCocos2dCompileDir,
- stdio: [0, 1, 'pipe']
- });
- child.on('error', function (err) {
- var ANT = Chalk.inverse('ant');
- if (err.code === 'ENOENT') {
- console.error(Chalk.red('You should install %s to build cocos2d-html5'), ANT);
- }
- else {
- console.error(Chalk.red('Failed to start %s') + ': %s', ANT, err.code);
- }
- process.exit(1);
- });
- child.stderr.on('data', function (data) {
- process.stderr.write(Chalk.red(data.toString()));
- });
- child.on('exit', function (code) {
- if (code === 0) {
- done();
- }
- else {
- process.exit(1);
- }
- });
-});
-
var header = new Buffer('(function (cc, ccui, ccs, sp, cp) {\n');
var footer = new Buffer('\n}).call(window, cc, ccui, ccs, sp, cp);\n');
@@ -287,38 +199,22 @@ function wrapFile (header, footer) {
);
}
-if (MinifyOriginCocos2d) {
- gulp.task('build-modular-cocos2d', ['compile-cocos2d'], function () {
- return gulp.src(paths.originCocos2dDev)
- .pipe(wrap(header, footer))
- .pipe(rename(Path.basename(paths.modularCocos2d)))
- .pipe(gulp.dest(Path.dirname(paths.modularCocos2d)));
- // gulp.src(paths.originCocos2d)
- // .pipe(wrap(header, footer))
- // .pipe(rename(Path.basename(paths.modularCocos2d)))
- // .pipe(gulp.dest(Path.dirname(paths.modularCocos2d)));
- // gulp.src(paths.originSourcemap)
- // .pipe(gulp.dest(Path.dirname(paths.modularCocos2d)));
- });
-}
-else {
- gulp.task('build-modular-cocos2d', function () {
- return gulp.src(srcs)
- .pipe(wrapFile(header, footer))
- .pipe(sourcemaps.init())
- .pipe(concat(Path.basename(paths.modularCocos2d)))
- .pipe(sourcemaps.write('./'))
- //.pipe(wrap(header, footer))
+gulp.task('build-modular-cocos2d', function () {
+ return gulp.src(srcs)
+ .pipe(wrapFile(header, footer))
+ .pipe(sourcemaps.init())
+ .pipe(concat(Path.basename(paths.modularCocos2d)))
+ .pipe(sourcemaps.write('./'))
+ //.pipe(wrap(header, footer))
- .pipe(es.through(
- function (file) {
- var content = file.contents.toString();
- content = content.replace(/\r\n/g , '\n');
- file.contents = new Buffer(content);
- this.emit('data', file);
- }
- ))
+ .pipe(es.through(
+ function (file) {
+ var content = file.contents.toString();
+ content = content.replace(/\r\n/g , '\n');
+ file.contents = new Buffer(content);
+ this.emit('data', file);
+ }
+ ))
- .pipe(gulp.dest(Path.dirname(paths.modularCocos2d)));
- });
-}
+ .pipe(gulp.dest(Path.dirname(paths.modularCocos2d)));
+});
diff --git a/gulp/tasks/build.js b/gulp/tasks/build.js
index 2caac0af7b..62a89dfbae 100644
--- a/gulp/tasks/build.js
+++ b/gulp/tasks/build.js
@@ -17,7 +17,8 @@ var handleErrors = require('../util/handleErrors');
require('./build-cocos2d');
-function getUglifyOptions (minify, global_defs) {
+function getUglifyOptions (minify, global_defs, preserveComments) {
+ preserveComments = preserveComments || false;
if (minify) {
return {
compress: {
@@ -51,7 +52,7 @@ function getUglifyOptions (minify, global_defs) {
// http://lisperator.net/uglifyjs/codegen
return {
mangle: false,
- preserveComments: 'all',
+ preserveComments: preserveComments,
output: {
beautify: true,
bracketize: true
@@ -196,13 +197,13 @@ gulp.task('build-jsb-extends-min', function () {
});
gulp.task('build-jsb-extends-dev', function () {
- var jsbPolyfill = rebundle_jsb(createBundler(paths.JSBEntries), false, '_polyfill');
+ var jsbPolyfill = rebundle_jsb(createBundler(paths.JSBEntries), false, '_polyfill.dev');
return jsbPolyfill;
});
-gulp.task('build', ['build-html5', 'build-jsb-extends-min']);
+gulp.task('build', ['build-html5', 'build-jsb-extends-min', 'build-jsb-extends-dev']);
-gulp.task('fast-build', ['build-test', 'build-jsb-extends-min'], function (done) {
+gulp.task('fast-build', ['build-test', 'build-jsb-extends-min', 'build-jsb-extends-dev'], function (done) {
Del(['./bin/cocos2d-js.js', './bin/cocos2d-js-min.js',], done);
});
diff --git a/gulp/tasks/clean.js b/gulp/tasks/clean.js
index 3b35d85669..00d8f9a6da 100644
--- a/gulp/tasks/clean.js
+++ b/gulp/tasks/clean.js
@@ -4,5 +4,4 @@ var del = require('del');
gulp.task('clean', function (done) {
del(Path.join(paths.outDir, '**/*'));
- del(paths.originCocos2d, done);
});
diff --git a/gulp/tasks/test.js b/gulp/tasks/test.js
index 11a7bed73e..5513774d0e 100644
--- a/gulp/tasks/test.js
+++ b/gulp/tasks/test.js
@@ -37,4 +37,4 @@ gulp.task('test', ['build-test', 'unit-runner'], test);
gulp.task('visual-test', ['build-test'], shell.task([
'sh ./test/visual-tests/run.sh'
]));
-gulp.task('rerun-test', test);
+gulp.task('test-no-build', test);
diff --git a/gulpfile.js b/gulpfile.js
index 2b8cdbc3d8..2dea6199df 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -9,8 +9,7 @@ paths = {
src: './src',
jsEntry: './index.js',
JSBEntries: [
- './jsb_predefine.js',
- './jsb_polyfill.js',
+ './jsb/index.js',
'./extends.js'
],
outDir: './bin',
@@ -22,7 +21,8 @@ paths = {
'../../cocos2d/core/textures/CCTexture2D',
'../../cocos2d/core/sprites/CCSpriteFrame',
'../../cocos2d/core/platform/CCLoader',
- '../../cocos2d/core/platform/CCLoaders'
+ '../../cocos2d/core/platform/CCLoaders',
+ '../../cocos2d/core/event/event',
],
test: {
@@ -33,9 +33,6 @@ paths = {
destEditorExtends: 'bin/cocos2d-js-extends-for-test.js'
},
- originCocos2dCompileDir: './tools',
- originCocos2d: './lib/cocos2d-js-v3.9-min.js',
- //originSourcemap: './lib/cocos2d-js-v3.9-sourcemap',
modularCocos2d: './bin/modular-cocos2d.js',
};
diff --git a/jsb/index.js b/jsb/index.js
new file mode 100644
index 0000000000..4416f9b461
--- /dev/null
+++ b/jsb/index.js
@@ -0,0 +1,37 @@
+'use strict';
+
+require('./jsb-predefine');
+require('./jsb-game');
+require('./jsb-director');
+require('./jsb-tex-sprite-frame');
+require('./jsb-label');
+require('./jsb-particle');
+require('./jsb-enums');
+require('./jsb-event');
+require('./jsb-etc');
+
+// Check version
+var _engineNumberVersion = (function () {
+ var result = /Cocos2d\-JS\sv([\d]+)\.([\d]+)/.exec(cc.ENGINE_VERSION);
+ if (result && result[1]) {
+ return {
+ major: parseInt(result[1]),
+ minor: parseInt(result[2])
+ };
+ }
+ else {
+ return null;
+ }
+})();
+
+// Version polyfills
+if (_engineNumberVersion) {
+ if (_engineNumberVersion.major === 3) {
+ if (_engineNumberVersion.minor < 9) {
+ require('./versions/jsb-polyfill-v3.8');
+ }
+ if (_engineNumberVersion.minor < 10) {
+ require('./versions/jsb-polyfill-v3.9');
+ }
+ }
+}
\ No newline at end of file
diff --git a/jsb_apis.js b/jsb/jsb-apis.js
similarity index 100%
rename from jsb_apis.js
rename to jsb/jsb-apis.js
diff --git a/jsb/jsb-director.js b/jsb/jsb-director.js
new file mode 100644
index 0000000000..d5a9ef5bfd
--- /dev/null
+++ b/jsb/jsb-director.js
@@ -0,0 +1,319 @@
+/****************************************************************************
+ Copyright (c) 2015 Chukong Technologies Inc.
+
+ http://www.cocos2d-x.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+'use strict';
+
+// cc.director
+cc.js.mixin(cc.director, {
+ /**
+ * Manage all init process shared between the web engine and jsb engine.
+ * All platform independent init process should be occupied here.
+ */
+ sharedInit: function () {
+ // Animation manager
+ if (cc.AnimationManager) {
+ this._animationManager = new cc.AnimationManager();
+ this.getScheduler().scheduleUpdate(this._animationManager, cc.Scheduler.PRIORITY_SYSTEM, false);
+ }
+ else {
+ this._animationManager = null;
+ }
+
+ // WidgetManager
+ cc._widgetManager.init(this);
+ },
+
+ /**
+ * Reset the cc.director, can be used to restart the director after purge
+ */
+ reset: function () {
+ this.purgeDirector();
+
+ if (cc.eventManager)
+ cc.eventManager.setEnabled(true);
+
+ // Action manager
+ var actionManager = this.getActionManager();
+ if (actionManager) {
+ this.getScheduler().scheduleUpdate(actionManager, cc.Scheduler.PRIORITY_SYSTEM, false);
+ }
+
+ // Animation manager
+ if (this._animationManager) {
+ this.getScheduler().scheduleUpdate(this._animationManager, cc.Scheduler.PRIORITY_SYSTEM, false);
+ }
+
+ this.startAnimation();
+ },
+
+ /**
+ * Returns the cc.AnimationManager associated with this director.
+ * @method getAnimationManager
+ * @return {AnimationManager}
+ */
+ getAnimationManager: function () {
+ return this._animationManager;
+ },
+
+ /**
+ * Returns current running Scene. Director can only run one Scene at the time.
+ * @method getScene
+ * @return {Scene}
+ */
+ getScene: function () {
+ return this._scene;
+ },
+
+ /**
+ * Run a scene. Replaces the running scene with a new one or enter the first scene.
+ * @method runScene
+ * @param {EScene} scene - The need run scene.
+ * @param {Function} [onBeforeLoadScene] - The function at the scene before loading.
+ */
+ runScene: function (scene, onBeforeLoadScene) {
+ cc.assert(scene, cc._LogInfos.Director.pushScene);
+
+ // detach persist nodes
+ var i, node, game = cc.game;
+ var persistNodes = game._persistRootNodes;
+ for (i = persistNodes.length - 1; i >= 0; --i) {
+ node = persistNodes[i];
+ game._ignoreRemovePersistNode = node;
+ node.parent = null;
+ game._ignoreRemovePersistNode = null;
+ }
+
+ // unload scene
+ var oldScene = this._scene;
+ if (cc.isValid(oldScene)) {
+ oldScene.destroy();
+ }
+ this._scene = null;
+
+ // purge destroyed nodes belongs to old scene
+ cc.Object._deferredDestroy();
+
+ if (onBeforeLoadScene) {
+ onBeforeLoadScene();
+ }
+ this.emit(cc.Director.EVENT_BEFORE_SCENE_LAUNCH, scene);
+
+ var sgScene = scene;
+
+ // Run an Entity Scene
+ if (scene instanceof cc.Scene) {
+ // ensure scene initialized
+ scene._load();
+
+ this._scene = scene;
+ sgScene = scene._sgNode;
+
+ // Re-attach persist nodes
+ for (i = 0; i < persistNodes.length; ++i) {
+ node = persistNodes[i];
+ node.parent = scene;
+ }
+ }
+
+ // Run or replace rendering scene
+ if (!this.getRunningScene()) {
+ this.runWithScene(sgScene);
+ }
+ else {
+ this.replaceScene(sgScene);
+ }
+
+ // Activate
+ if (scene instanceof cc.Scene) {
+ scene._activate();
+ }
+ },
+
+ // @Scene loading section
+
+ /**
+ * Loads the scene by its name.
+ * @method loadScene
+ * @param {String} sceneName - The name of the scene to load.
+ * @param {Function} [onLaunched] - callback, will be called after scene launched.
+ * @param {Function} [onUnloaded] - callback, will be called when the previous scene was unloaded.
+ * @return {Boolean} if error, return false
+ */
+ loadScene: function (sceneName, onLaunched, onUnloaded) {
+ var uuid, info;
+ if (this._loadingScene) {
+ cc.error('[loadScene] Failed to load scene "%s" because "%s" is already loading', sceneName, this._loadingScene);
+ return false;
+ }
+ if (typeof sceneName === 'string') {
+ if (!sceneName.endsWith('.fire')) {
+ sceneName += '.fire';
+ }
+ if (sceneName[0] !== '/' && !sceneName.startsWith('db://assets/')) {
+ sceneName = '/' + sceneName; // 使用全名匹配
+ }
+ // search scene
+ for (var i = 0; i < cc.game._sceneInfos.length; i++) {
+ info = cc.game._sceneInfos[i];
+ var url = info.url;
+ if (url.endsWith(sceneName)) {
+ uuid = info.uuid;
+ break;
+ }
+ }
+ }
+ else {
+ info = cc.game._sceneInfos[sceneName];
+ if (typeof info === 'object') {
+ uuid = info.uuid;
+ }
+ else {
+ cc.error('[loadScene] The scene index to load (%s) is out of range.', sceneName);
+ return false;
+ }
+ }
+ if (uuid) {
+ this._loadingScene = sceneName;
+ this._loadSceneByUuid(uuid, onLaunched, onUnloaded);
+ return true;
+ }
+ else {
+ cc.error('[loadScene] Can not load the scene "%s" because it has not been added to the build settings before play.', sceneName);
+ return false;
+ }
+ },
+
+ // load raw assets
+ _loadRawAssets: function (assetObjects, done) {
+ var urls = assetObjects.map(function (asset) {
+ return asset.url;
+ });
+
+ //var info = 'preload ' + urls;
+ //console.time(info);
+
+ // currently cocos jsb 3.3 not support preload too much assets
+ // so we divide assets to 30 a group
+ var index = 0;
+ var count = 30;
+ var total = urls.length;
+
+ function preload () {
+ if (index + count > total) {
+ // the last time
+ count = total - index;
+ }
+
+ var assets = urls.slice(index, count);
+
+ index += count;
+
+ if (index < total) {
+ cc.loader.load(assets, preload);
+ }
+ else {
+ //console.timeEnd(info);
+ done();
+ }
+ }
+
+ preload();
+ },
+
+ /**
+ * Loads the scene by its uuid.
+ * @method _loadSceneByUuid
+ * @param {String} uuid - the uuid of the scene asset to load
+ * @param {Function} [onLaunched]
+ * @param {Function} [onUnloaded]
+ * @private
+ */
+ _loadSceneByUuid: function (uuid, onLaunched, onUnloaded) {
+ //cc.AssetLibrary.unloadAsset(uuid); // force reload
+ cc.AssetLibrary.loadAsset(uuid, function (error, sceneAsset) {
+ var self = cc.director;
+ var scene;
+ if (error) {
+ error = 'Failed to load scene: ' + error;
+ cc.error(error);
+ if (CC_EDITOR) {
+ console.assert(false, error);
+ }
+ }
+ else {
+ var uuid = sceneAsset._uuid;
+ scene = sceneAsset.scene;
+ if (scene instanceof cc.Scene) {
+ scene._id = uuid;
+ self.runScene(scene, onUnloaded);
+ }
+ else {
+ error = 'The asset ' + uuid + ' is not a scene';
+ cc.error(error);
+ scene = null;
+ }
+ }
+ self._loadingScene = '';
+ if (onLaunched) {
+ onLaunched(error, scene);
+ }
+ }, { recordAssets: true });
+ }
+});
+
+cc.EventTarget.call(cc.director);
+cc.js.addon(cc.director, cc.EventTarget.prototype);
+
+cc.Director.EVENT_PROJECTION_CHANGED = 'director_projection_changed';
+cc.Director.EVENT_AFTER_DRAW = 'director_after_draw';
+cc.Director.EVENT_BEFORE_VISIT = 'director_before_visit';
+cc.Director.EVENT_AFTER_VISIT = 'director_after_visit';
+cc.Director.EVENT_BEFORE_UPDATE = 'director_before_update';
+cc.Director.EVENT_AFTER_UPDATE = 'director_after_update';
+cc.Director.EVENT_BEFORE_SCENE_LAUNCH = 'director_before_scene_launch';
+cc.Director.EVENT_COMPONENT_UPDATE = 'director_component_update';
+cc.Director.EVENT_COMPONENT_LATE_UPDATE = 'director_component_late_update';
+
+cc.eventManager.addCustomListener(cc.Director.EVENT_BEFORE_UPDATE, function () {
+ var dt = 1 / cc.game.config[cc.game.CONFIG_KEY.frameRate];
+ // Call start for new added components
+ cc.director.emit(cc.Director.EVENT_BEFORE_UPDATE);
+ // Update for components
+ cc.director.emit(cc.Director.EVENT_COMPONENT_UPDATE, dt);
+});
+cc.eventManager.addCustomListener(cc.Director.EVENT_AFTER_UPDATE, function () {
+ var dt = 1 / cc.game.config[cc.game.CONFIG_KEY.frameRate];
+ // Late update for components
+ cc.director.emit(cc.Director.EVENT_COMPONENT_LATE_UPDATE, dt);
+ // User can use this event to do things after update
+ cc.director.emit(cc.Director.EVENT_AFTER_UPDATE);
+
+ cc.director.emit(cc.Director.EVENT_BEFORE_VISIT, this);
+});
+cc.eventManager.addCustomListener(cc.Director.EVENT_AFTER_VISIT, function () {
+ cc.director.emit(cc.Director.EVENT_AFTER_VISIT, this);
+});
+cc.eventManager.addCustomListener(cc.Director.EVENT_AFTER_DRAW, function () {
+ cc.director.emit(cc.Director.EVENT_AFTER_DRAW, this);
+});
\ No newline at end of file
diff --git a/jsb/jsb-enums.js b/jsb/jsb-enums.js
new file mode 100644
index 0000000000..459c4aa61a
--- /dev/null
+++ b/jsb/jsb-enums.js
@@ -0,0 +1,308 @@
+/****************************************************************************
+ Copyright (c) 2015 Chukong Technologies Inc.
+
+ http://www.cocos2d-x.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+'use strict';
+
+cc.ProgressTimer.Type = cc.Enum({
+ /**
+ * Radial Counter-Clockwise
+ */
+ RADIAL: 0,
+ BAR: 1
+});
+
+
+cc.EditBox.InputMode = cc.Enum({
+
+ ANY: 0,
+
+ /**
+ * The user is allowed to enter an e-mail address.
+ */
+ EMAILADDR: 1,
+
+ /**
+ * The user is allowed to enter an integer value.
+ */
+ NUMERIC: 2,
+
+ /**
+ * The user is allowed to enter a phone number.
+ */
+ PHONENUMBER: 3,
+
+ /**
+ * The user is allowed to enter a URL.
+ */
+ URL: 4,
+
+ /**
+ * The user is allowed to enter a real number value.
+ * This extends kEditBoxInputModeNumeric by allowing a decimal point.
+ */
+ DECIMAL: 5,
+
+ /**
+ * The user is allowed to enter any text, except for line breaks.
+ */
+ SINGLELINE: 6
+});
+
+/**
+ * Enum for the EditBox's input flags
+ * @readonly
+ * @enum {number}
+ * @memberof cc.EditBox
+ */
+cc.EditBox.InputFlag = cc.Enum({
+ /**
+ * Indicates that the text entered is confidential data that should be
+ * obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE.
+ */
+ PASSWORD: 0,
+
+ /**
+ * Indicates that the text entered is sensitive data that the
+ * implementation must never store into a dictionary or table for use
+ * in predictive, auto-completing, or other accelerated input schemes.
+ * A credit card number is an example of sensitive data.
+ */
+ SENSITIVE: 1,
+
+ /**
+ * This flag is a hint to the implementation that during text editing,
+ * the initial letter of each word should be capitalized.
+ */
+ INITIAL_CAPS_WORD: 2,
+
+ /**
+ * This flag is a hint to the implementation that during text editing,
+ * the initial letter of each sentence should be capitalized.
+ */
+ INITIAL_CAPS_SENTENCE: 3,
+
+ /**
+ * Capitalize all characters automatically.
+ */
+ INITIAL_CAPS_ALL_CHARACTERS: 4
+});
+
+/**
+ * Enum for keyboard return types
+ * @readonly
+ * @enum {number}
+ */
+cc.KeyboardReturnType = cc.Enum({
+ DEFAULT: 0,
+ DONE: 1,
+ SEND: 2,
+ SEARCH: 3,
+ GO: 4
+});
+
+/**
+ * Enum for text alignment
+ * @readonly
+ * @enum {number}
+ */
+cc.TextAlignment = cc.Enum({
+ LEFT: 0,
+ CENTER: 1,
+ RIGHT: 2
+});
+
+/**
+ * Enum for vertical text alignment
+ * @readonly
+ * @enum {number}
+ */
+cc.VerticalTextAlignment = cc.Enum({
+ TOP: 0,
+ CENTER: 1,
+ BOTTOM: 2
+});
+
+/**
+ * Enum for Relative layout parameter RelativeAlign
+ * @readonly
+ * @enum {number}
+ */
+ccui.RelativeLayoutParameter.Type = cc.Enum({
+ /**
+ * The none of ccui.RelativeLayoutParameter's relative align.
+ */
+ NONE: 0,
+ /**
+ * The parent's top left of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_TOP_LEFT: 1,
+ /**
+ * The parent's top center horizontal of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_TOP_CENTER_HORIZONTAL: 2,
+ /**
+ * The parent's top right of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_TOP_RIGHT: 3,
+ /**
+ * The parent's left center vertical of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_LEFT_CENTER_VERTICAL: 4,
+
+ /**
+ * The center in parent of ccui.RelativeLayoutParameter's relative align.
+ */
+ CENTER_IN_PARENT: 5,
+
+ /**
+ * The parent's right center vertical of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_RIGHT_CENTER_VERTICAL: 6,
+ /**
+ * The parent's left bottom of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_LEFT_BOTTOM: 7,
+ /**
+ * The parent's bottom center horizontal of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_BOTTOM_CENTER_HORIZONTAL: 8,
+ /**
+ * The parent's right bottom of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_RIGHT_BOTTOM: 9,
+
+ /**
+ * The location above left align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_ABOVE_LEFTALIGN: 10,
+ /**
+ * The location above center of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_ABOVE_CENTER: 11,
+ /**
+ * The location above right align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_ABOVE_RIGHTALIGN: 12,
+ /**
+ * The location left of top align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_LEFT_OF_TOPALIGN: 13,
+ /**
+ * The location left of center of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_LEFT_OF_CENTER: 14,
+ /**
+ * The location left of bottom align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_LEFT_OF_BOTTOMALIGN: 15,
+ /**
+ * The location right of top align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_RIGHT_OF_TOPALIGN: 16,
+ /**
+ * The location right of center of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_RIGHT_OF_CENTER: 17,
+ /**
+ * The location right of bottom align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_RIGHT_OF_BOTTOMALIGN: 18,
+ /**
+ * The location below left align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_BELOW_LEFTALIGN: 19,
+ /**
+ * The location below center of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_BELOW_CENTER: 20,
+ /**
+ * The location below right align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_BELOW_RIGHTALIGN: 21
+});
+
+
+/**
+ * Enum for layout type
+ * @readonly
+ * @enum {number}
+ */
+ccui.Layout.Type = cc.Enum({
+ /**
+ * The absolute of ccui.Layout's layout type.
+ */
+ ABSOLUTE: 0,
+ /**
+ * The vertical of ccui.Layout's layout type.
+ */
+ LINEAR_VERTICAL: 1,
+ /**
+ * The horizontal of ccui.Layout's layout type.
+ */
+ LINEAR_HORIZONTAL: 2,
+ /**
+ * The relative of ccui.Layout's layout type.
+ */
+ RELATIVE: 3
+});
+
+/**
+ * Enum for loadingBar Type
+ * @readonly
+ * @enum {number}
+ */
+ccui.LoadingBar.Type = cc.Enum({
+ /**
+ * The left direction of ccui.LoadingBar.
+ */
+ LEFT: 0,
+ /**
+ * The right direction of ccui.LoadingBar.
+ */
+ RIGHT: 1
+});
+
+/**
+ * Enum for ScrollView direction
+ * @readonly
+ * @enum {number}
+ */
+ccui.ScrollView.Dir = cc.Enum({
+ /**
+ * The none flag of ccui.ScrollView's direction.
+ */
+ NONE: 0,
+ /**
+ * The vertical flag of ccui.ScrollView's direction.
+ */
+ VERTICAL: 1,
+ /**
+ * The horizontal flag of ccui.ScrollView's direction.
+ */
+ HORIZONTAL: 2,
+ /**
+ * The both flag of ccui.ScrollView's direction.
+ */
+ BOTH: 3
+});
\ No newline at end of file
diff --git a/jsb/jsb-etc.js b/jsb/jsb-etc.js
new file mode 100644
index 0000000000..f0bb3c56c6
--- /dev/null
+++ b/jsb/jsb-etc.js
@@ -0,0 +1,127 @@
+/****************************************************************************
+ Copyright (c) 2015 Chukong Technologies Inc.
+
+ http://www.cocos2d-x.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+'use strict';
+
+// cc.path
+cc.js.mixin(cc.path, {
+ //todo make public after verification
+ _normalize: function(url){
+ var oldUrl = url = String(url);
+
+ //removing all ../
+ do {
+ oldUrl = url;
+ url = url.replace(this.normalizeRE, '');
+ } while(oldUrl.length !== url.length);
+ return url;
+ },
+
+ // The platform-specific file separator. '\\' or '/'.
+ sep: (cc.sys.os === cc.sys.OS_WINDOWS ? '\\' : '/'),
+
+ // @param {string} path
+ // @param {boolean|string} [endsWithSep = true]
+ // @returns {string}
+ _setEndWithSep: function (path, endsWithSep) {
+ var sep = cc.path.sep;
+ if (typeof endsWithSep === 'undefined') {
+ endsWithSep = true;
+ }
+ else if (typeof endsWithSep === 'string') {
+ sep = endsWithSep;
+ endsWithSep = !!endsWithSep;
+ }
+
+ var endChar = path[path.length - 1];
+ var oldEndWithSep = (endChar === '\\' || endChar === '/');
+ if (!oldEndWithSep && endsWithSep) {
+ path += sep;
+ }
+ else if (oldEndWithSep && !endsWithSep) {
+ path = path.slice(0, -1);
+ }
+ return path;
+ }
+});
+
+// cc.Scheduler
+cc.Scheduler.prototype.scheduleUpdate = cc.Scheduler.prototype.scheduleUpdateForTarget;
+cc.Scheduler.prototype._unschedule = cc.Scheduler.prototype.unschedule;
+cc.Scheduler.prototype.unschedule = function (callback, target) {
+ if (typeof target === 'function') {
+ var tmp = target;
+ target = callback;
+ callback = tmp;
+ }
+ this._unschedule(target, callback);
+};
+
+// cc.Scale9Sprite
+cc.Scale9Sprite.prototype._setBlendFunc = cc.Scale9Sprite.prototype.setBlendFunc;
+cc.Scale9Sprite.prototype.setBlendFunc = function(blendFunc, dst) {
+ if (dst !== undefined) {
+ blendFunc = {
+ src : blendFunc,
+ dst : dst
+ };
+ }
+ this._setBlendFunc(blendFunc);
+};
+cc.Scale9Sprite.prototype._setContentSize = cc.Scale9Sprite.prototype.setContentSize;
+cc.Scale9Sprite.prototype.setContentSize = function(size, height){
+ if (height !== undefined) {
+ size = new cc.Size(size, height);
+ }
+ this._setContentSize(size);
+};
+cc.Scale9Sprite.prototype._setAnchorPoint = cc.Scale9Sprite.prototype.setAnchorPoint;
+cc.Scale9Sprite.prototype.setAnchorPoint = function(anchorPoint, y){
+ if (y !== undefined) {
+ anchorPoint = new cc.Vec2(anchorPoint, y);
+ }
+ this._setAnchorPoint(anchorPoint);
+};
+
+cc.Scale9Sprite.prototype._setSpriteFrame = cc.Scale9Sprite.prototype.setSpriteFrame;
+cc.Scale9Sprite.prototype.setSpriteFrame = function(spriteFrame) {
+ var contentSize = this.getContentSize();
+ this._setSpriteFrame(spriteFrame);
+ if (!cc.sizeEqualToSize(contentSize, cc.size(0, 0))) {
+ this.setContentSize(contentSize);
+ }
+};
+
+// ccsg
+window._ccsg = {
+ Node: cc.Node,
+ Scene: cc.Scene,
+ Sprite: cc.Sprite,
+ ParticleSystem: cc.ParticleSystem,
+ Label: cc.Label,
+
+};
+
+// rename cc.Class to cc._Class
+cc._Class = cc.Class;
diff --git a/jsb/jsb-event.js b/jsb/jsb-event.js
new file mode 100644
index 0000000000..6eec9db7b1
--- /dev/null
+++ b/jsb/jsb-event.js
@@ -0,0 +1,160 @@
+/****************************************************************************
+ Copyright (c) 2015 Chukong Technologies Inc.
+
+ http://www.cocos2d-x.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+'use strict';
+
+// cc.Event
+cc.Event.NO_TYPE = 'no_type';
+cc.Event.NONE = 0;
+cc.Event.CAPTURING_PHASE = 1;
+cc.Event.AT_TARGET = 2;
+cc.Event.BUBBLING_PHASE = 3;
+
+cc.Event.prototype._getCurrentTarget = cc.Event.prototype.getCurrentTarget;
+cc.Event.prototype.getCurrentTarget = function () {
+ return this.currentTarget || this._getCurrentTarget();
+};
+cc.Event.prototype._stopPropagation = cc.Event.prototype.stopPropagation;
+cc.Event.prototype.stopPropagation = function () {
+ this._propagationStopped = true;
+ this._stopPropagation();
+};
+cc.Event.prototype._isStopped = cc.Event.prototype.isStopped;
+cc.Event.prototype.isStopped = function () {
+ return this._propagationStopped || this._propagationImmediateStopped || this._isStopped();
+};
+cc.js.mixin(cc.Event.prototype, {
+ type: 'no_type',
+ target: null,
+ currentTarget: null,
+ eventPhase: 0,
+ bubbles: false,
+ _defaultPrevented: false,
+ _propagationStopped: false,
+ _propagationImmediateStopped: false,
+
+ unuse: function () {
+ this.type = cc.Event.NO_TYPE;
+ this.target = null;
+ this.currentTarget = null;
+ this.eventPhase = cc.Event.NONE;
+ this._defaultPrevented = false;
+ this._propagationStopped = false;
+ this._propagationImmediateStopped = false;
+ },
+ reuse: function (type, bubbles) {
+ this.type = type;
+ this.bubbles = bubbles || false;
+ },
+ preventDefault: function () {
+ this._defaultPrevented = true;
+ },
+ stopPropagationImmediate: function () {
+ this._propagationImmediateStopped = true;
+ },
+});
+
+// cc.Event.EventCustom
+cc.Event.EventCustom = function (type, bubbles) {
+ cc.Event.call(this, cc.Event.CUSTOM);
+ this.type = type;
+ this.bubbles = bubbles || false;
+ this.detail = null;
+};
+cc.js.extend(cc.Event.EventCustom, cc.Event);
+cc.js.mixin(cc.Event.EventCustom.prototype, {
+ setUserData: function (data) {
+ this.detail = data;
+ },
+ getUserData: function () {
+ return this.detail;
+ },
+ getEventName: cc.Event.prototype.getType
+});
+
+// cc.eventManager.addListener
+cc.eventManager.addListener = function(listener, nodeOrPriority) {
+ if(!(listener instanceof cc.EventListener)) {
+ listener = cc.EventListener.create(listener);
+ }
+
+ if (typeof nodeOrPriority === 'number') {
+ if (nodeOrPriority === 0) {
+ cc.log('0 priority is forbidden for fixed priority since it\'s used for scene graph based priority.');
+ return;
+ }
+
+ cc.eventManager.addEventListenerWithFixedPriority(listener, nodeOrPriority);
+ } else {
+ var node = nodeOrPriority;
+ if (nodeOrPriority instanceof cc.Component) {
+ node = nodeOrPriority.node._sgNode;
+ }
+ if (nodeOrPriority instanceof cc.Node) {
+ node = nodeOrPriority._sgNode;
+ }
+ // rebind target
+ if (node !== nodeOrPriority) {
+ var keys = Object.keys(listener);
+ // Overwrite all functions
+ for (var i = 0; i < keys.length; ++i) {
+ var key = keys[i];
+ var value = listener[key];
+ if (typeof value === 'function') {
+ // var _value = value;
+ listener[key] = (function (realCallback) {
+ return function (event1, event2) {
+ // event must be the last argument, and arguments count could be 1 or 2
+ var event = event2 || event1;
+ // Augment event object to fit cc.Event
+ if (event) {
+ event.target = nodeOrPriority;
+ event.currentTarget = nodeOrPriority;
+ event.bubbles = false;
+ event.eventPhase = 0;
+ event._defaultPrevented = false;
+ event._propagationStopped = false;
+ event._propagationImmediateStopped = false;
+ }
+ return realCallback.call(this, event1, event2);
+ };
+ })(value);
+ }
+ }
+ }
+ cc.eventManager.addEventListenerWithSceneGraphPriority(listener, node);
+ }
+
+ return listener;
+};
+cc.eventManager._removeListeners = cc.eventManager.removeListeners;
+cc.eventManager.removeListeners = function (target, recursive) {
+ if (target instanceof cc.Component) {
+ target = target.node._sgNode;
+ }
+ if (target instanceof cc.Node) {
+ target = target._sgNode;
+ }
+ this._removeListeners(target, recursive);
+};
\ No newline at end of file
diff --git a/jsb/jsb-game.js b/jsb/jsb-game.js
new file mode 100644
index 0000000000..628ecf2933
--- /dev/null
+++ b/jsb/jsb-game.js
@@ -0,0 +1,240 @@
+/****************************************************************************
+ Copyright (c) 2015 Chukong Technologies Inc.
+
+ http://www.cocos2d-x.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+'use strict';
+
+// cc.game
+cc.js.mixin(cc.game, {
+
+ // states
+ _paused: false, //whether the game is paused
+
+ // Scenes list
+ _sceneInfos: [],
+
+ _persistRootNodes: [],
+ _ignoreRemovePersistNode: null,
+
+ CONFIG_KEY: {
+ width: 'width',
+ height: 'height',
+ engineDir: 'engineDir',
+ modules: 'modules',
+ debugMode: 'debugMode',
+ showFPS: 'showFPS',
+ frameRate: 'frameRate',
+ id: 'id',
+ renderMode: 'renderMode',
+ registerSystemEvent: 'registerSystemEvent',
+ jsList: 'jsList',
+ scenes: 'scenes'
+ },
+
+ pause: function () {
+ this._paused = true;
+ cc.director.pause();
+ },
+
+ /**
+ * Resume the game from pause.
+ */
+ resume: function () {
+ this._paused = false;
+ cc.director.resume();
+ },
+
+ /**
+ * Check whether the game is paused.
+ */
+ isPaused: function () {
+ return this._paused;
+ },
+
+ prepare: function (cb) {
+ var self = this,
+ config = self.config,
+ CONFIG_KEY = self.CONFIG_KEY;
+
+ this._loadConfig();
+
+ // Already prepared
+ if (this._prepared) {
+ if (cb) cb();
+ return;
+ }
+ // Prepare called, but not done yet
+ if (this._prepareCalled) {
+ return;
+ }
+ // Prepare never called and engine ready
+ if (cc._engineLoaded) {
+ this._prepareCalled = true;
+
+ // Additional step in JSB
+ cc.director.sharedInit();
+
+ // Load game scripts
+ var jsList = config[CONFIG_KEY.jsList];
+ if (jsList) {
+ cc.loader.loadJs(jsList, function (err) {
+ if (err) throw new Error(err);
+ self._prepared = true;
+ if (cb) cb();
+ });
+ }
+ else {
+ if (cb) cb();
+ }
+
+ return;
+ }
+
+ // Engine not loaded yet
+ cc.initEngine(this.config, function () {
+ self.prepare(cb);
+ });
+ },
+
+ /**
+ * Run game with configuration object and onStart function.
+ * @param {Object|Function} [config] Pass configuration object or onStart function
+ * @param {onStart} [onStart] onStart function to be executed after game initialized
+ */
+ run: function (config, onStart) {
+ if (typeof config === 'function') {
+ cc.game.onStart = config;
+ }
+ else {
+ if (config) {
+ cc.game.config = config;
+ }
+ if (typeof onStart === 'function') {
+ cc.game.onStart = onStart;
+ }
+ }
+
+ this.prepare(cc.game.onStart && cc.game.onStart.bind(cc.game));
+ },
+
+// @ Persist root node section
+ /**
+ * Add a persistent root node to the game, the persistent node won't be destroyed during scene transition
+ * @method addPersistRootNode
+ * @param {ENode} node - The node to be made persistent
+ */
+ addPersistRootNode: function (node) {
+ if (!(node instanceof cc.Node))
+ return;
+ var index = this._persistRootNodes.indexOf(node);
+ if (index === -1) {
+ var scene = cc.director._scene;
+ if (cc.isValid(scene)) {
+ if (!node.parent) {
+ node.parent = scene;
+ }
+ else if ( !(node.parent instanceof cc.Scene) ) {
+ cc.warn('The node can not be made persist because it\'s not under root node.');
+ return;
+ }
+ else if (node.parent !== scene) {
+ cc.warn('The node can not be made persist because it\'s not in current scene.');
+ return;
+ }
+ this._persistRootNodes.push(node);
+ node._persistNode = true;
+ }
+ }
+ },
+
+ /**
+ * Remove a persistent root node
+ * @method removePersistRootNode
+ * @param {ENode} node - The node to be removed from persistent node list
+ */
+ removePersistRootNode: function (node) {
+ if (node !== this._ignoreRemovePersistNode) {
+ var index = this._persistRootNodes.indexOf(node);
+ if (index !== -1) {
+ this._persistRootNodes.splice(index, 1);
+ }
+ node._persistNode = false;
+ }
+ },
+
+ /**
+ * Check whether the node is a persistent root node
+ * @method isPersistRootNode
+ * @param {ENode} node - The node to be checked
+ * @return {Boolean}
+ */
+ isPersistRootNode: function (node) {
+ return node._persistNode;
+ },
+
+//@Private Methods
+
+ _loadConfig: function () {
+ // Load config
+ // Already loaded
+ if (this.config) {
+ this._initConfig(this.config);
+ }
+ // Load from project.json
+ else {
+ try {
+ var txt = jsb.fileUtils.getStringFromFile('project.json');
+ var data = JSON.parse(txt);
+ this._initConfig(data || {});
+ } catch (e) {
+ console.log('Failed to read or parse project.json');
+ this._initConfig({});
+ }
+ }
+ },
+
+ _initConfig: function (config) {
+ var CONFIG_KEY = this.CONFIG_KEY;
+
+ // Configs adjustment
+ config[CONFIG_KEY.showFPS] = config[CONFIG_KEY.showFPS] || true;
+ config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || 'frameworks/cocos2d-html5';
+ if (config[CONFIG_KEY.debugMode] == null)
+ config[CONFIG_KEY.debugMode] = 0;
+ config[CONFIG_KEY.frameRate] = config[CONFIG_KEY.frameRate] || 60;
+ if (config[CONFIG_KEY.renderMode] == null)
+ config[CONFIG_KEY.renderMode] = 0;
+
+ // Scene parser
+ this._sceneInfos = this._sceneInfos.concat(config[CONFIG_KEY.scenes]);
+
+ cc.director.setDisplayStats(this.config[CONFIG_KEY.showFPS]);
+ cc.director.setAnimationInterval(1.0/this.config[CONFIG_KEY.frameRate]);
+
+ this.config = config;
+ }
+});
+
+
+cc.EventTarget.call(cc.game);
+cc.js.addon(cc.game, cc.EventTarget.prototype);
\ No newline at end of file
diff --git a/jsb/jsb-label.js b/jsb/jsb-label.js
new file mode 100644
index 0000000000..faa4d9a453
--- /dev/null
+++ b/jsb/jsb-label.js
@@ -0,0 +1,126 @@
+/****************************************************************************
+ Copyright (c) 2015 Chukong Technologies Inc.
+
+ http://www.cocos2d-x.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+'use strict';
+
+// cc.Label
+var jsbLabel = cc.Label;
+jsbLabel.prototype.setHorizontalAlign = jsbLabel.prototype.setHorizontalAlignment;
+jsbLabel.prototype.setVerticalAlign = jsbLabel.prototype.setVerticalAlignment;
+//for back compatibility
+if (!jsbLabel.prototype.setBMFontSize) {
+ jsbLabel.prototype.setBMFontSize = function(){};
+}
+if (!jsbLabel.prototype.getBMFontSize) {
+ jsbLabel.prototype.getBMFontSize = function(){};
+}
+if (!jsbLabel.prototype.setOverflow) {
+ jsbLabel.prototype.setOverflow = function(){};
+}
+if (!jsbLabel.prototype.getOverflow) {
+ jsbLabel.prototype.getOverflow = function(){};
+}
+
+jsbLabel.prototype.setFontSize = function (size) {
+ if (this._labelType === _ccsg.Label.Type.SystemFont) {
+ this.setSystemFontSize(size);
+ }
+ else if (this._labelType === _ccsg.Label.Type.BMFont) {
+ this.setBMFontSize(size);
+ }
+ else if (this._labelType === _ccsg.Label.Type.TTF) {
+ var ttfConfig = this.getTTFConfig();
+ ttfConfig.fontSize = size;
+ this.setTTFConfig(ttfConfig);
+ }
+};
+
+jsbLabel.prototype.enableWrapText = jsbLabel.prototype.enableWrap || function(){};
+jsbLabel.prototype.isWrapTextEnabled = jsbLabel.prototype.isWrapEnabled || function(){};
+
+jsbLabel.prototype._setLineHeight = jsbLabel.prototype.setLineHeight;
+jsbLabel.prototype.setLineHeight = function (height) {
+ if (this._labelType !== _ccsg.Label.Type.SystemFont) {
+ this._setLineHeight(height);
+ }
+};
+
+jsbLabel.prototype._setTTFConfig = jsbLabel.prototype.setTTFConfig;
+jsbLabel.prototype.setTTFConfig = function (config) {
+ this._setTTFConfig(config);
+ this._ttfConfig = config;
+};
+jsbLabel.prototype.getTTFConfig = function () {
+ return this._ttfConfig;
+};
+
+jsbLabel.prototype.setContentSize = function(size, height) {
+ if(height !== undefined){
+ this.setDimensions(size, height);
+ }
+ else{
+ this.setDimensions(size.width, size.height);
+ }
+};
+cc.Label = function (string, fontHandle) {
+ fontHandle = fontHandle || "Arial";
+ var extName = cc.path.extname(fontHandle);
+
+ var type = _ccsg.Label.Type.TTF;
+
+ var label;
+ if (extName === ".ttf") {
+ var ttfConfig = {
+ fontFilePath: fontHandle,
+ fontSize: 40,
+ outlineSize: 0,
+ glyphs: 0,
+ customGlyphs: "",
+ distanceFieldEnable: false
+ };
+ label = jsbLabel.createWithTTF(ttfConfig, string, 40);
+ label._ttfConfig = ttfConfig;
+ }
+ else if (extName === ".fnt") {
+ label = jsbLabel.createWithBMFont(fontHandle, string);
+ type = _ccsg.Label.Type.BMFont;
+ }
+ else {
+ label = jsbLabel.createWithSystemFont(string, fontHandle, 40);
+ type = _ccsg.Label.Type.SystemFont;
+ }
+ label._labelType = type;
+ return label;
+};
+cc.Label.Type = cc.Enum({
+ TTF: 0,
+ BMFont: 1
+});
+cc.Label.Overflow = cc.Enum({
+ //TODO: uncomment if normal is supported in web
+ // NONE: 0,
+ CLAMP: 1,
+ SHRINK: 2,
+ RESIZE_HEIGHT: 3
+});
\ No newline at end of file
diff --git a/jsb/jsb-particle.js b/jsb/jsb-particle.js
new file mode 100644
index 0000000000..8f4f4d4bf3
--- /dev/null
+++ b/jsb/jsb-particle.js
@@ -0,0 +1,94 @@
+/****************************************************************************
+ Copyright (c) 2015 Chukong Technologies Inc.
+
+ http://www.cocos2d-x.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+'use strict';
+
+cc.ParticleSystem.Mode = cc.Enum({
+ /** The gravity mode (A mode) */
+ GRAVITY: 0,
+ /** The radius mode (B mode) */
+ RADIUS: 1
+});
+
+
+cc.ParticleSystem.Type = cc.Enum({
+ /**
+ * Living particles are attached to the world and are unaffected by emitter repositioning.
+ */
+ FREE: 0,
+
+ /**
+ * Living particles are attached to the world but will follow the emitter repositioning.
+ * Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite.
+ */
+ RELATIVE: 1,
+
+ /**
+ * Living particles are attached to the emitter and are translated along with it.
+ */
+ GROUPED: 2
+});
+
+var funcNames = [
+ {
+ 'tangentialAccel' : 'setTangentialAccel',
+ 'tangentialAccelVar' : 'setTangentialAccelVar',
+ 'radialAccel' : 'setRadialAccel',
+ 'radialAccelVar' : 'setRadialAccelVar',
+ 'rotationIsDir' : 'setRotationIsDir',
+ 'gravity' : 'setGravity',
+ 'speed' : 'setSpeed',
+ 'speedVar' : 'setSpeedVar'
+ },
+ {
+ 'startRadius' : 'setStartRadius',
+ 'startRadiusVar' : 'setStartRadiusVar',
+ 'endRadius' : 'setEndRadius',
+ 'endRadiusVar' : 'setEndRadiusVar',
+ 'rotatePerS' : 'setRotatePerSecond',
+ 'rotatePerSVar' : 'setRotatePerSecondVar'
+ }
+];
+
+function getReplacer (oldFunc, mode) {
+ return function (value) {
+ if (this.getEmitterMode() === mode) {
+ oldFunc.call(this, value);
+ }
+ };
+}
+
+var proto = cc.ParticleSystem.prototype;
+
+for (var mode = 0; mode < funcNames.length; mode++) {
+ var modeFuncs = funcNames[mode];
+ for (var propName in modeFuncs) {
+ var funcName = modeFuncs[propName];
+ var func = proto[funcName];
+ proto[funcName] = getReplacer(func, mode);
+
+ var getter = funcName.replace('set', 'get');
+ cc.defineGetterSetter(proto, propName, proto[getter], proto[funcName]);
+ }
+}
diff --git a/jsb/jsb-predefine.js b/jsb/jsb-predefine.js
new file mode 100644
index 0000000000..4ee476b5f5
--- /dev/null
+++ b/jsb/jsb-predefine.js
@@ -0,0 +1,57 @@
+/****************************************************************************
+ Copyright (c) 2015 Chukong Technologies Inc.
+
+ http://www.cocos2d-x.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+// Run jsb.js before all polyfills
+cc.initEngine({
+ debugMode: cc.game.DEBUG_MODE_INFO
+});
+
+if (!cc.ClassManager) {
+ cc.ClassManager = window.ClassManager || {
+ id : (0|(Math.random()*998)),
+ instanceId : (0|(Math.random()*998)),
+ getNewID : function(){
+ return this.id++;
+ },
+ getNewInstanceId : function(){
+ return this.instanceId++;
+ }
+ };
+}
+
+if (CC_DEV) {
+ /**
+ * contains internal apis for unit tests
+ * @expose
+ */
+ cc._Test = {};
+}
+
+// predefine some modules for cocos
+
+require('../cocos2d/core/platform/js');
+require('../cocos2d/core/value-types');
+require('../cocos2d/core/utils/find');
+require('../cocos2d/core/event');
+require('../CCDebugger');
diff --git a/jsb/jsb-tex-sprite-frame.js b/jsb/jsb-tex-sprite-frame.js
new file mode 100644
index 0000000000..a0b67e4e43
--- /dev/null
+++ b/jsb/jsb-tex-sprite-frame.js
@@ -0,0 +1,186 @@
+/****************************************************************************
+ Copyright (c) 2015 Chukong Technologies Inc.
+
+ http://www.cocos2d-x.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+'use strict';
+
+cc.spriteFrameAnimationCache = cc.animationCache;
+cc.SpriteFrameAnimation = cc.Animation;
+
+// cc.textureCache.cacheImage
+cc.textureCache._textures = {};
+cc.textureCache.cacheImage = function (key, texture) {
+ if (texture instanceof cc.Texture2D) {
+ this._textures[key] = texture;
+ }
+};
+cc.textureCache._getTextureForKey = cc.textureCache.getTextureForKey;
+cc.textureCache.getTextureForKey = function (key) {
+ var tex = this._getTextureForKey(key);
+ if (!tex)
+ tex = this._textures[key];
+ return tex || null;
+};
+
+// cc.Texture2D
+cc.Texture2D.prototype.isLoaded = function () {
+ return true;
+};
+cc.Texture2D.prototype.getPixelWidth = cc.Texture2D.prototype.getPixelsWide;
+cc.Texture2D.prototype.getPixelHeight = cc.Texture2D.prototype.getPixelsHigh;
+
+// cc.SpriteFrame
+cc.js.mixin(cc.SpriteFrame.prototype, cc.EventTarget.prototype);
+cc.SpriteFrame.prototype.textureLoaded = function () {
+ return this.getTexture() !== null;
+};
+cc.SpriteFrame.prototype._initWithTexture = cc.SpriteFrame.prototype.initWithTexture;
+cc.SpriteFrame.prototype.initWithTexture = function (texture, rect, rotated, offset, originalSize, _uuid) {
+ function check(texture) {
+ if (texture && texture.isLoaded()) {
+ var _x, _y;
+ if (rotated) {
+ _x = rect.x + rect.height;
+ _y = rect.y + rect.width;
+ }
+ else {
+ _x = rect.x + rect.width;
+ _y = rect.y + rect.height;
+ }
+ if (_x > texture.getPixelWidth()) {
+ cc.error(cc._LogInfos.RectWidth, _uuid);
+ }
+ if (_y > texture.getPixelHeight()) {
+ cc.error(cc._LogInfos.RectHeight, _uuid);
+ }
+ }
+ }
+
+ if(arguments.length === 2)
+ rect = cc.rectPointsToPixels(rect);
+
+ offset = cc.p(0, 0);
+ originalSize = originalSize || rect;
+ rotated = rotated || false;
+
+ if (this.insetTop === undefined) {
+ this.insetTop = 0;
+ this.insetBottom = 0;
+ this.insetLeft = 0;
+ this.insetRight = 0;
+ }
+
+ var locTexture;
+ if (!texture && _uuid) {
+ // deserialize texture from uuid
+ var info = cc.AssetLibrary._getAssetInfoInRuntime(_uuid);
+ if (!info) {
+ cc.error('SpriteFrame: Failed to load sprite texture "%s"', _uuid);
+ return;
+ }
+
+ this._textureFilename = info.url;
+
+ locTexture = cc.textureCache.addImage(info.url);
+ this._initWithTexture(locTexture, rect, rotated, offset, originalSize);
+ }
+ else {
+ if (cc.js.isString(texture)){
+ this._textureFilename = texture;
+ locTexture = cc.textureCache.addImage(this._textureFilename);
+ this._initWithTexture(locTexture, rect, rotated, offset, originalSize);
+ } else if (texture instanceof cc.Texture2D) {
+ this._textureFilename = '';
+ this._initWithTexture(texture, rect, rotated, offset, originalSize);
+ }
+ }
+ this.emit('load');
+ check(this.getTexture());
+ return true;
+};
+cc.SpriteFrame.prototype._deserialize = function (data, handle) {
+ var rect = data.rect ? new cc.Rect(data.rect[0], data.rect[1], data.rect[2], data.rect[3]) : undefined;
+ var offset = data.offset ? new cc.Vec2(data.offset[0], data.offset[1]) : undefined;
+ var size = data.originalSize ? new cc.Size(data.originalSize[0], data.originalSize[1]) : undefined;
+ var rotated = data.rotated === 1;
+ // init properties not included in this._initWithTexture()
+ this._name = data.name;
+ var capInsets = data.capInsets;
+ if (capInsets) {
+ this.insetLeft = capInsets[0];
+ this.insetTop = capInsets[1];
+ this.insetRight = capInsets[2];
+ this.insetBottom = capInsets[3];
+ }
+
+ // load texture via _textureFilenameSetter
+ var textureUuid = data.texture;
+ if (textureUuid) {
+ handle.result.push(this, '_textureFilenameSetter', textureUuid);
+ }
+
+ this.initWithTexture(null, rect, rotated, offset, size, textureUuid);
+};
+cc.SpriteFrame.prototype._checkRect = function (texture) {
+ var rect = this.getRectInPixels();
+ var maxX = rect.x, maxY = rect.y;
+ if (this._rotated) {
+ maxX += rect.height;
+ maxY += rect.width;
+ }
+ else {
+ maxX += rect.width;
+ maxY += rect.height;
+ }
+ if (maxX > texture.getPixelWidth()) {
+ cc.error(cc._LogInfos.RectWidth, texture.url);
+ }
+ if (maxY > texture.getPixelHeight()) {
+ cc.error(cc._LogInfos.RectHeight, texture.url);
+ }
+};
+var getTextureJSB = cc.SpriteFrame.prototype.getTexture;
+cc.SpriteFrame.prototype.getTexture = function () {
+ var tex = getTextureJSB.call(this);
+ this._texture = tex;
+ return tex;
+};
+cc.js.set(cc.SpriteFrame.prototype, '_textureFilenameSetter', function (url) {
+ this._textureFilename = url;
+ if (url) {
+ // texture will be init in getTexture()
+ var texture = this.getTexture();
+ if (this.textureLoaded()) {
+ this._checkRect(texture);
+ this.emit('load');
+ }
+ else {
+ // register event in setTexture()
+ this._texture = null;
+ this.setTexture(texture);
+ }
+ }
+});
+
+// Assets
+cc.js.setClassName('cc.SpriteFrame', cc.SpriteFrame);
diff --git a/jsb_predefine.js b/jsb/versions/jsb-polyfill-v3.8.js
similarity index 76%
rename from jsb_predefine.js
rename to jsb/versions/jsb-polyfill-v3.8.js
index 36bb623f71..0545adbd09 100644
--- a/jsb_predefine.js
+++ b/jsb/versions/jsb-polyfill-v3.8.js
@@ -22,20 +22,15 @@
THE SOFTWARE.
****************************************************************************/
+'use strict';
-// define cc
-
-if (CC_DEV) {
- /**
- * contains internal apis for unit tests
- * @expose
- */
- cc._Test = {};
-}
-
-// predefine some modules for cocos
-
-require('./polyfill');
-require('./cocos2d/core/platform/js');
-require('./cocos2d/core/value-types');
-require('./cocos2d/core/event');
+// Overwrite main loop
+var scheduleTarget = {
+ update: function (dt) {
+ // Call start for new added components
+ cc.director.emit(cc.Director.EVENT_BEFORE_UPDATE);
+ // Update for components
+ cc.director.emit(cc.Director.EVENT_COMPONENT_UPDATE, dt);
+ }
+};
+cc.Director.getInstance().getScheduler().scheduleUpdateForTarget(scheduleTarget, -1000, false);
\ No newline at end of file
diff --git a/jsb/versions/jsb-polyfill-v3.9.js b/jsb/versions/jsb-polyfill-v3.9.js
new file mode 100644
index 0000000000..2093161531
--- /dev/null
+++ b/jsb/versions/jsb-polyfill-v3.9.js
@@ -0,0 +1,42 @@
+/****************************************************************************
+ Copyright (c) 2015 Chukong Technologies Inc.
+
+ http://www.cocos2d-x.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+'use strict';
+
+cc.Scale9Sprite.prototype.setRenderingType = function (type) {
+ if (this._renderingType === type) return;
+ this._renderingType = type;
+
+ if (!this.isScale9Enabled()){
+ this.setScale9Enabled(true);
+ }
+
+ if (type === cc.SpriteType.SIMPLE) {
+ // Should modify based on trim size
+ this.setInsetLeft(0);
+ this.setInsetTop(0);
+ this.setInsetBottom(0);
+ this.setInsetRight(0);
+ }
+};
\ No newline at end of file
diff --git a/jsb_engine.js b/jsb_engine.js
deleted file mode 100644
index 0f20719525..0000000000
--- a/jsb_engine.js
+++ /dev/null
@@ -1,448 +0,0 @@
-'use strict';
-
-function _getPropertyDescriptor (obj, name) {
- var pd = Object.getOwnPropertyDescriptor(obj, name);
- if (pd) {
- return pd;
- }
- var p = Object.getPrototypeOf(obj);
- if (p) {
- return _getPropertyDescriptor(p, name);
- }
- else {
- return null;
- }
-}
-
-function _copyprop(name, source, target) {
- var pd = _getPropertyDescriptor(source, name);
- Object.defineProperty(target, name, pd);
-}
-
-function mixin (obj) {
- obj = obj || {};
- for (var i = 1, length = arguments.length; i < length; i++) {
- var source = arguments[i];
- if (source) {
- if (typeof source !== 'object') {
- cc.error('mixin: arguments must be type object:', source);
- continue;
- }
- for ( var name in source) {
- _copyprop( name, source, obj);
- }
- }
- }
- return obj;
-}
-
-cc.js = {
- mixin: mixin
-};
-
-cc.initEngine = function (config, cb) {
- require('script/jsb.js');
- cc._renderType = cc.game.RENDER_TYPE_OPENGL;
- cc._initDebugSetting(config[cc.game.CONFIG_KEY.debugMode]);
- cc._engineLoaded = true;
- cc.log(cc.ENGINE_VERSION);
- if (cb) cb();
-};
-
-// cc.game
-mixin(cc.game, {
-
- // states
- _paused: false, //whether the game is paused
-
- // Scenes list
- _sceneInfos: [],
-
- _persistRootNodes: [],
-
- CONFIG_KEY: {
- width: 'width',
- height: 'height',
- engineDir: 'engineDir',
- modules: 'modules',
- debugMode: 'debugMode',
- showFPS: 'showFPS',
- frameRate: 'frameRate',
- id: 'id',
- renderMode: 'renderMode',
- registerSystemEvent: 'registerSystemEvent',
- jsList: 'jsList',
- scenes: 'scenes'
- },
-
- pause: function () {
- this._paused = true;
- cc.director.pause();
- },
-
- /**
- * Resume the game from pause.
- */
- resume: function () {
- this._paused = false;
- cc.director.resume();
- },
-
- /**
- * Check whether the game is paused.
- */
- isPaused: function () {
- return this._paused;
- },
-
- prepare: function (cb) {
- var self = this,
- config = self.config,
- CONFIG_KEY = self.CONFIG_KEY;
-
- this._loadConfig();
-
- // Already prepared
- if (this._prepared) {
- if (cb) cb();
- return;
- }
- // Prepare called, but not done yet
- if (this._prepareCalled) {
- return;
- }
- // Prepare never called and engine ready
- if (cc._engineLoaded) {
- this._prepareCalled = true;
- // Load game scripts
- var jsList = config[CONFIG_KEY.jsList];
- if (jsList) {
- cc.loader.loadJs(jsList, function (err) {
- if (err) throw new Error(err);
- self._prepared = true;
- if (cb) cb();
- });
- }
- else {
- if (cb) cb();
- }
-
- return;
- }
-
- // Engine not loaded yet
- cc.initEngine(this.config, function () {
- self.prepare(cb);
- });
- },
-
- /**
- * Run game with configuration object and onStart function.
- * @param {Object|Function} [config] Pass configuration object or onStart function
- * @param {onStart} [onStart] onStart function to be executed after game initialized
- */
- run: function (config, onStart) {
- if (typeof config === 'function') {
- cc.game.onStart = config;
- }
- else {
- if (config) {
- cc.game.config = config;
- }
- if (typeof onStart === 'function') {
- cc.game.onStart = onStart;
- }
- }
-
- this.prepare(cc.game.onStart && cc.game.onStart.bind(cc.game));
- },
-
-// @ Persist root node section
- /**
- * Add a persistent root node to the game, the persistent node won't be destroyed during scene transition
- * @method addPersistRootNode
- * @param {ENode} node - The node to be made persistent
- */
- addPersistRootNode: function (node) {
- if (!(node instanceof cc.Node))
- return;
- var index = this._persistRootNodes.indexOf(node);
- if (index === -1) {
- var scene = cc.director._scene;
- if (cc.isValid(scene)) {
- if (!node.parent) {
- node.parent = scene;
- }
- else if (node.parent !== scene) {
- cc.warn('The node can not be made persist because it\'s not under root node.');
- return;
- }
- this._persistRootNodes.push(node);
- node._persistNode = true;
- }
- }
- },
-
- /**
- * Remove a persistent root node
- * @method removePersistRootNode
- * @param {ENode} node - The node to be removed from persistent node list
- */
- removePersistRootNode: function (node) {
- var index = this._persistRootNodes.indexOf(node);
- if (index !== -1) {
- this._persistRootNodes.splice(index, 1);
- }
- node._persistNode = false;
- },
-
- /**
- * Check whether the node is a persistent root node
- * @method isPersistRootNode
- * @param {ENode} node - The node to be checked
- * @return {Boolean}
- */
- isPersistRootNode: function (node) {
- return node._persistNode;
- },
-
-//@Private Methods
-
- _loadConfig: function () {
- // Load config
- // Already loaded
- if (this.config) {
- this._initConfig(this.config);
- }
- // Load from project.json
- else {
- try {
- var txt = jsb.fileUtils.getStringFromFile('project.json');
- var data = JSON.parse(txt);
- this._initConfig(data || {});
- } catch (e) {
- console.log('Failed to read or parse project.json');
- this._initConfig({});
- }
- }
- },
-
- _initConfig: function (config) {
- var CONFIG_KEY = this.CONFIG_KEY;
-
- // Configs adjustment
- config[CONFIG_KEY.showFPS] = config[CONFIG_KEY.showFPS] || true;
- config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || 'frameworks/cocos2d-html5';
- if (config[CONFIG_KEY.debugMode] == null)
- config[CONFIG_KEY.debugMode] = 0;
- config[CONFIG_KEY.frameRate] = config[CONFIG_KEY.frameRate] || 60;
- if (config[CONFIG_KEY.renderMode] == null)
- config[CONFIG_KEY.renderMode] = 0;
-
- // Scene parser
- this._sceneInfos = this._sceneInfos.concat(config[CONFIG_KEY.scenes]);
-
- cc.director.setDisplayStats(this.config[CONFIG_KEY.showFPS]);
- cc.director.setAnimationInterval(1.0/this.config[CONFIG_KEY.frameRate]);
-
- this.config = config;
- }
-});
-
-// cc.director
-mixin(cc.director, {
- /**
- * Manage all init process shared between the web engine and jsb engine.
- * All platform independent init process should be occupied here.
- */
- sharedInit: function () {
- // Animation manager
- if (cc.AnimationManager) {
- this._animationManager = new cc.AnimationManager();
- this._scheduler.scheduleUpdate(this._animationManager, cc.Scheduler.PRIORITY_SYSTEM, false);
- }
- else {
- this._animationManager = null;
- }
-
- // WidgetManager
- cc._widgetManager.init(this);
- },
-
- /**
- * Reset the cc.director, can be used to restart the director after purge
- */
- reset: function () {
- this.purgeDirector();
-
- if (cc.eventManager)
- cc.eventManager.setEnabled(true);
-
- // Action manager
- var actionManager = this.getActionManager();
- if (actionManager) {
- this.getScheduler().scheduleUpdate(actionManager, cc.Scheduler.PRIORITY_SYSTEM, false);
- }
-
- // Animation manager
- if (this._animationManager) {
- this.getScheduler().scheduleUpdate(this._animationManager, cc.Scheduler.PRIORITY_SYSTEM, false);
- }
-
- this.startAnimation();
- },
-
- /**
- * Run a scene. Replaces the running scene with a new one or enter the first scene.
- * @method runScene
- * @param {EScene} scene - The need run scene.
- * @param {Function} [onBeforeLoadScene] - The function at the scene before loading.
- */
- runScene: function (scene, onBeforeLoadScene) {
- // cc.assert(scene, cc._LogInfos.Director.pushScene);
-
- // unload scene
- var oldScene = this._scene;
- if (cc.isValid(oldScene)) {
- oldScene.destroy();
- }
- this._scene = null;
-
- // purge destroyed nodes belongs to old scene
- cc.Object._deferredDestroy();
-
- if (onBeforeLoadScene) {
- onBeforeLoadScene();
- }
- this.emit(cc.Director.EVENT_BEFORE_SCENE_LAUNCH, scene);
-
- // Re-add persist node root
- var persistNodes = cc.game._persistRootNodes;
- for (var i = 0; i < persistNodes.length; ++i) {
- var node = persistNodes[i];
- node.parent = scene;
- }
-
- var sgScene = scene;
-
- // Run an Entity Scene
- if (scene instanceof cc.Scene) {
- // ensure scene initialized
- scene._load();
-
- this._scene = scene;
- sgScene = scene._sgNode;
- }
-
- // Run or replace rendering scene
- if (!this.getRunningScene()) {
- this.runWithScene(sgScene);
- }
- else {
- this.replaceScene(sgScene);
- }
-
- // Activate
- if (scene instanceof cc.Scene) {
- scene._activate();
- }
- },
-
- // @Scene loading section
-
- /**
- * Loads the scene by its name.
- * @method loadScene
- * @param {String} sceneName - The name of the scene to load.
- * @param {Function} [onLaunched] - callback, will be called after scene launched.
- * @param {Function} [onUnloaded] - callback, will be called when the previous scene was unloaded.
- * @return {Boolean} if error, return false
- */
- loadScene: function (sceneName, onLaunched, onUnloaded) {
- var uuid, info;
- if (this._loadingScene) {
- cc.error('[loadScene] Failed to load scene "%s" because "%s" is already loading', sceneName, this._loadingScene);
- return false;
- }
- if (typeof sceneName === 'string') {
- if (!sceneName.endsWith('.fire')) {
- sceneName += '.fire';
- }
- if (sceneName[0] !== '/' && !sceneName.startsWith('db://assets/')) {
- sceneName = '/' + sceneName; // 使用全名匹配
- }
- // search scene
- for (var i = 0; i < cc.game._sceneInfos.length; i++) {
- info = cc.game._sceneInfos[i];
- var url = info.url;
- if (url.endsWith(sceneName)) {
- uuid = info.uuid;
- break;
- }
- }
- }
- else {
- info = cc.game._sceneInfos[sceneName];
- if (typeof info === 'object') {
- uuid = info.uuid;
- }
- else {
- cc.error('[loadScene] The scene index to load (%s) is out of range.', sceneName);
- return false;
- }
- }
- if (uuid) {
- this._loadingScene = sceneName;
- this._loadSceneByUuid(uuid, onLaunched, onUnloaded);
- return true;
- }
- else {
- cc.error('[loadScene] Can not load the scene "%s" because it has not been added to the build settings before play.', sceneName);
- return false;
- }
- },
-
- /**
- * Loads the scene by its uuid.
- * @method _loadSceneByUuid
- * @param {String} uuid - the uuid of the scene asset to load
- * @param {Function} [onLaunched]
- * @param {Function} [onUnloaded]
- * @private
- */
- _loadSceneByUuid: function (uuid, onLaunched, onUnloaded) {
- //cc.AssetLibrary.unloadAsset(uuid); // force reload
- cc.AssetLibrary.loadAsset(uuid, function (error, sceneAsset) {
- var scene;
- if (error) {
- error = 'Failed to load scene: ' + error;
- cc.error(error);
- if (CC_EDITOR) {
- console.assert(false, error);
- }
- }
- else {
- var uuid = sceneAsset._uuid;
- scene = sceneAsset.scene;
- if (scene instanceof cc.Scene) {
- scene._id = uuid;
- cc.director.runScene(scene, onUnloaded);
- }
- else {
- error = 'The asset ' + uuid + ' is not a scene';
- cc.error(error);
- scene = null;
- }
- }
- cc.director._loadingScene = '';
- if (onLaunched) {
- onLaunched(error, scene);
- }
- });
- }
-});
-
-cc.director.sharedInit();
-
-cc._LogInfos = {};
-
diff --git a/jsb_polyfill.js b/jsb_polyfill.js
deleted file mode 100644
index 1f6cc2ef0b..0000000000
--- a/jsb_polyfill.js
+++ /dev/null
@@ -1,583 +0,0 @@
-'use strict';
-
-cc.ParticleSystem.Mode = cc.Enum({
- /** The gravity mode (A mode) */
- GRAVITY: 0,
- /** The radius mode (B mode) */
- RADIUS: 1
-});
-
-cc.ParticleSystem.Type = cc.Enum({
- /**
- * Living particles are attached to the world and are unaffected by emitter repositioning.
- */
- FREE: 0,
-
- /**
- * Living particles are attached to the world but will follow the emitter repositioning.
- * Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite.
- */
- RELATIVE: 1,
-
- /**
- * Living particles are attached to the emitter and are translated along with it.
- */
- GROUPED: 2
-});
-
-cc.ProgressTimer.Type = cc.Enum({
- /**
- * Radial Counter-Clockwise
- */
- RADIAL: 0,
- BAR: 1
-});
-
-
-cc.EditBox.InputMode = cc.Enum({
-
- ANY: 0,
-
- /**
- * The user is allowed to enter an e-mail address.
- */
- EMAILADDR: 1,
-
- /**
- * The user is allowed to enter an integer value.
- */
- NUMERIC: 2,
-
- /**
- * The user is allowed to enter a phone number.
- */
- PHONENUMBER: 3,
-
- /**
- * The user is allowed to enter a URL.
- */
- URL: 4,
-
- /**
- * The user is allowed to enter a real number value.
- * This extends kEditBoxInputModeNumeric by allowing a decimal point.
- */
- DECIMAL: 5,
-
- /**
- * The user is allowed to enter any text, except for line breaks.
- */
- SINGLELINE: 6
-});
-
-/**
- * Enum for the EditBox's input flags
- * @readonly
- * @enum {number}
- * @memberof cc.EditBox
- */
-cc.EditBox.InputFlag = cc.Enum({
- /**
- * Indicates that the text entered is confidential data that should be
- * obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE.
- */
- PASSWORD: 0,
-
- /**
- * Indicates that the text entered is sensitive data that the
- * implementation must never store into a dictionary or table for use
- * in predictive, auto-completing, or other accelerated input schemes.
- * A credit card number is an example of sensitive data.
- */
- SENSITIVE: 1,
-
- /**
- * This flag is a hint to the implementation that during text editing,
- * the initial letter of each word should be capitalized.
- */
- INITIAL_CAPS_WORD: 2,
-
- /**
- * This flag is a hint to the implementation that during text editing,
- * the initial letter of each sentence should be capitalized.
- */
- INITIAL_CAPS_SENTENCE: 3,
-
- /**
- * Capitalize all characters automatically.
- */
- INITIAL_CAPS_ALL_CHARACTERS: 4
-});
-
-/**
- * Enum for keyboard return types
- * @readonly
- * @enum {number}
- */
-cc.KeyboardReturnType = cc.Enum({
- DEFAULT: 0,
- DONE: 1,
- SEND: 2,
- SEARCH: 3,
- GO: 4
-});
-
-/**
- * Enum for text alignment
- * @readonly
- * @enum {number}
- */
-cc.TextAlignment = cc.Enum({
- LEFT: 0,
- CENTER: 1,
- RIGHT: 2
-});
-
-/**
- * Enum for vertical text alignment
- * @readonly
- * @enum {number}
- */
-cc.VerticalTextAlignment = cc.Enum({
- TOP: 0,
- CENTER: 1,
- BOTTOM: 2
-});
-
-/**
- * Enum for Relative layout parameter RelativeAlign
- * @readonly
- * @enum {number}
- */
-ccui.RelativeLayoutParameter.Type = cc.Enum({
- /**
- * The none of ccui.RelativeLayoutParameter's relative align.
- */
- NONE: 0,
- /**
- * The parent's top left of ccui.RelativeLayoutParameter's relative align.
- */
- PARENT_TOP_LEFT: 1,
- /**
- * The parent's top center horizontal of ccui.RelativeLayoutParameter's relative align.
- */
- PARENT_TOP_CENTER_HORIZONTAL: 2,
- /**
- * The parent's top right of ccui.RelativeLayoutParameter's relative align.
- */
- PARENT_TOP_RIGHT: 3,
- /**
- * The parent's left center vertical of ccui.RelativeLayoutParameter's relative align.
- */
- PARENT_LEFT_CENTER_VERTICAL: 4,
-
- /**
- * The center in parent of ccui.RelativeLayoutParameter's relative align.
- */
- CENTER_IN_PARENT: 5,
-
- /**
- * The parent's right center vertical of ccui.RelativeLayoutParameter's relative align.
- */
- PARENT_RIGHT_CENTER_VERTICAL: 6,
- /**
- * The parent's left bottom of ccui.RelativeLayoutParameter's relative align.
- */
- PARENT_LEFT_BOTTOM: 7,
- /**
- * The parent's bottom center horizontal of ccui.RelativeLayoutParameter's relative align.
- */
- PARENT_BOTTOM_CENTER_HORIZONTAL: 8,
- /**
- * The parent's right bottom of ccui.RelativeLayoutParameter's relative align.
- */
- PARENT_RIGHT_BOTTOM: 9,
-
- /**
- * The location above left align of ccui.RelativeLayoutParameter's relative align.
- */
- LOCATION_ABOVE_LEFTALIGN: 10,
- /**
- * The location above center of ccui.RelativeLayoutParameter's relative align.
- */
- LOCATION_ABOVE_CENTER: 11,
- /**
- * The location above right align of ccui.RelativeLayoutParameter's relative align.
- */
- LOCATION_ABOVE_RIGHTALIGN: 12,
- /**
- * The location left of top align of ccui.RelativeLayoutParameter's relative align.
- */
- LOCATION_LEFT_OF_TOPALIGN: 13,
- /**
- * The location left of center of ccui.RelativeLayoutParameter's relative align.
- */
- LOCATION_LEFT_OF_CENTER: 14,
- /**
- * The location left of bottom align of ccui.RelativeLayoutParameter's relative align.
- */
- LOCATION_LEFT_OF_BOTTOMALIGN: 15,
- /**
- * The location right of top align of ccui.RelativeLayoutParameter's relative align.
- */
- LOCATION_RIGHT_OF_TOPALIGN: 16,
- /**
- * The location right of center of ccui.RelativeLayoutParameter's relative align.
- */
- LOCATION_RIGHT_OF_CENTER: 17,
- /**
- * The location right of bottom align of ccui.RelativeLayoutParameter's relative align.
- */
- LOCATION_RIGHT_OF_BOTTOMALIGN: 18,
- /**
- * The location below left align of ccui.RelativeLayoutParameter's relative align.
- */
- LOCATION_BELOW_LEFTALIGN: 19,
- /**
- * The location below center of ccui.RelativeLayoutParameter's relative align.
- */
- LOCATION_BELOW_CENTER: 20,
- /**
- * The location below right align of ccui.RelativeLayoutParameter's relative align.
- */
- LOCATION_BELOW_RIGHTALIGN: 21
-});
-
-
-/**
- * Enum for layout type
- * @readonly
- * @enum {number}
- */
-ccui.Layout.Type = cc.Enum({
- /**
- * The absolute of ccui.Layout's layout type.
- */
- ABSOLUTE: 0,
- /**
- * The vertical of ccui.Layout's layout type.
- */
- LINEAR_VERTICAL: 1,
- /**
- * The horizontal of ccui.Layout's layout type.
- */
- LINEAR_HORIZONTAL: 2,
- /**
- * The relative of ccui.Layout's layout type.
- */
- RELATIVE: 3
-});
-
-/**
- * Enum for loadingBar Type
- * @readonly
- * @enum {number}
- */
-ccui.LoadingBar.Type = cc.Enum({
- /**
- * The left direction of ccui.LoadingBar.
- */
- LEFT: 0,
- /**
- * The right direction of ccui.LoadingBar.
- */
- RIGHT: 1
-});
-
-/**
- * Enum for ScrollView direction
- * @readonly
- * @enum {number}
- */
-ccui.ScrollView.Dir = cc.Enum({
- /**
- * The none flag of ccui.ScrollView's direction.
- */
- NONE: 0,
- /**
- * The vertical flag of ccui.ScrollView's direction.
- */
- VERTICAL: 1,
- /**
- * The horizontal flag of ccui.ScrollView's direction.
- */
- HORIZONTAL: 2,
- /**
- * The both flag of ccui.ScrollView's direction.
- */
- BOTH: 3
-});
-
-require("CCDebugger");
-
-cc.js.mixin(cc.path, {
- //todo make public after verification
- _normalize: function(url){
- var oldUrl = url = String(url);
-
- //removing all ../
- do {
- oldUrl = url;
- url = url.replace(this.normalizeRE, '');
- } while(oldUrl.length !== url.length);
- return url;
- },
-
- // The platform-specific file separator. '\\' or '/'.
- sep: (cc.sys.os === cc.sys.OS_WINDOWS ? '\\' : '/'),
-
- // @param {string} path
- // @param {boolean|string} [endsWithSep = true]
- // @returns {string}
- _setEndWithSep: function (path, endsWithSep) {
- var sep = cc.path.sep;
- if (typeof endsWithSep === 'undefined') {
- endsWithSep = true;
- }
- else if (typeof endsWithSep === 'string') {
- sep = endsWithSep;
- endsWithSep = !!endsWithSep;
- }
-
- var endChar = path[path.length - 1];
- var oldEndWithSep = (endChar === '\\' || endChar === '/');
- if (!oldEndWithSep && endsWithSep) {
- path += sep;
- }
- else if (oldEndWithSep && !endsWithSep) {
- path = path.slice(0, -1);
- }
- return path;
- }
-});
-
-cc.EventTarget.call(cc.game);
-cc.js.addon(cc.game, cc.EventTarget.prototype);
-cc.EventTarget.call(cc.director);
-cc.js.addon(cc.director, cc.EventTarget.prototype);
-
-// cc.Label
-cc._Label = cc.Label;
-cc.Label = function (string, fontHandle, type) {
- var label;
- if (type === cc.Label.Type.TTF) {
- label = cc._Label.createWithSystemFont(string, fontHandle, 40);
- }
- else if (type === cc.Label.Type.BMFont) {
- label = cc._Label.createWithBMFont(fontHandle, string);
- }
- return label;
-};
-cc.Label.Type = cc.Enum({
- TTF: 0,
- BMFont: 1
-});
-cc.Label.Overflow = cc.Enum({
- CLAMP: 0,
- SHRINK: 1,
- RESIZE: 2
-});
-
-cc.spriteFrameAnimationCache = cc.animationCache;
-cc.SpriteFrameAnimation = cc.Animation;
-
-// Assets
-cc.js.setClassName('cc.SpriteFrame', cc.SpriteFrame);
-
-// ccsg
-window._ccsg = {
- Node: cc.Node,
- Scene: cc.Scene,
- Sprite: cc.Sprite,
- ParticleSystem: cc.ParticleSystem,
- Label: cc.Label,
-
-};
-
-// rename cc.Class to cc._Class
-cc._Class = cc.Class;
-
-// cc.textureCache.cacheImage
-cc.textureCache._textures = {};
-cc.textureCache.cacheImage = function (key, texture) {
- if (texture instanceof cc.Texture2D) {
- this._textures[key] = texture;
- }
-};
-cc.textureCache._getTextureForKey = cc.textureCache.getTextureForKey;
-cc.textureCache.getTextureForKey = function (key) {
- var tex = this._getTextureForKey(key);
- if (!tex)
- tex = this._textures[key];
- return tex || null;
-};
-
-// cc.Texture2D
-cc.Texture2D.prototype.isLoaded = function () {
- return true;
-};
-cc.Texture2D.prototype.getPixelWidth = cc.Texture2D.prototype.getPixelsWide;
-cc.Texture2D.prototype.getPixelHeight = cc.Texture2D.prototype.getPixelsHigh;
-
-// cc.SpriteFrame
-cc.SpriteFrame.prototype.textureLoaded = function () {
- return this.getTexture() !== null;
-};
-cc.SpriteFrame.prototype._deserialize = function (data, handle) {
- var rect = data.rect;
- rect = new cc.Rect(rect[0], rect[1], rect[2], rect[3]);
- var rectInP = cc.rectPointsToPixels(rect);
- var offset = new cc.Vec2(data.offset[0], data.offset[1]);
- var offsetInP = cc.pointPointsToPixels(offset);
- var size = new cc.Size(data.originalSize[0], data.originalSize[1]);
- var sizeInP = cc.sizePointsToPixels(size);
- var rotated = data.rotated === 1;
- // init properties not included in this._initWithTexture()
- this._name = data.name;
- var capInsets = data.capInsets;
- if (capInsets) {
- this.insetLeft = capInsets[0];
- this.insetTop = capInsets[1];
- this.insetRight = capInsets[2];
- this.insetBottom = capInsets[3];
- }
-
- // load texture via _textureFilenameSetter
- var textureUuid = data.texture;
- if (textureUuid) {
- handle.result.push(this, '_textureFilenameSetter', textureUuid);
- }
-
- this.initWithTexture(null, rectInP, rotated, offsetInP, sizeInP);
-};
-cc.SpriteFrame.prototype._checkRect = function (texture) {
- var rect = this._rectInPixels;
- var maxX = rect.x, maxY = rect.y;
- if (this._rotated) {
- maxX += rect.height;
- maxY += rect.width;
- }
- else {
- maxX += rect.width;
- maxY += rect.height;
- }
- if (maxX > texture.getPixelWidth()) {
- cc.error(cc._LogInfos.RectWidth, texture.url);
- }
- if (maxY > texture.getPixelHeight()) {
- cc.error(cc._LogInfos.RectHeight, texture.url);
- }
-};
-var getTextureJSB = cc.SpriteFrame.prototype.getTexture;
-cc.SpriteFrame.prototype.getTexture = function () {
- var tex = getTextureJSB.call(this);
- this._texture = tex;
- return tex;
-};
-cc.js.set(cc.SpriteFrame.prototype, '_textureFilenameSetter', function (url) {
- this._textureFilename = url;
- if (url) {
- // texture will be init in getTexture()
- var texture = this.getTexture();
- if (this.textureLoaded()) {
- this._checkRect(texture);
- this.emit('load');
- }
- else {
- // register event in setTexture()
- this._texture = null;
- this.setTexture(texture);
- }
- }
-});
-
-// cc.Label
-cc.Label.prototype.setHorizontalAlign = cc.Label.prototype.setHorizontalAlignment;
-cc.Label.prototype.setVerticalAlign = cc.Label.prototype.setVerticalAlignment;
-cc.Label.prototype.setFontSize = cc.Label.prototype.setSystemFontSize;
-cc.Label.prototype.setOverflow = function () {};
-cc.Label.prototype.enableWrapText = function () {};
-cc.Label.prototype.setLineHeight = function () {};
-
-// cc.Event#getCurrentTarget
-cc.Event.prototype._getCurrentTarget = cc.Event.prototype.getCurrentTarget;
-cc.Event.prototype.getCurrentTarget = function () {
- return this._currentTarget || this._getCurrentTarget();
-};
-
-// cc.eventManager.addListener
-cc.eventManager.addListener = function(listener, nodeOrPriority) {
- if(!(listener instanceof cc.EventListener)) {
- listener = cc.EventListener.create(listener);
- }
-
- if (typeof nodeOrPriority == "number") {
- if (nodeOrPriority == 0) {
- cc.log("0 priority is forbidden for fixed priority since it's used for scene graph based priority.");
- return;
- }
-
- cc.eventManager.addEventListenerWithFixedPriority(listener, nodeOrPriority);
- } else {
- var node = nodeOrPriority;
- if (nodeOrPriority instanceof cc.Component) {
- node = nodeOrPriority.node._sgNode;
- }
- if (nodeOrPriority instanceof cc.Node) {
- node = nodeOrPriority._sgNode;
- }
- // rebind target
- if (node !== nodeOrPriority) {
- var keys = Object.keys(listener);
- // Overwrite all functions
- for (var i = 0; i < keys.length; ++i) {
- var key = keys[i];
- var value = listener[key];
- if (typeof value === 'function') {
- // var _value = value;
- listener[key] = function (event1, event2) {
- // event must be the last argument, and arguments count could be 1 or 2
- var event = event2 || event1;
- // Replace event's _currentTarget
- if (event) {
- event._currentTarget = nodeOrPriority;
- }
- value.call(this, event1, event2);
- };
- }
- }
- }
- cc.eventManager.addEventListenerWithSceneGraphPriority(listener, node);
- }
-
- return listener;
-};
-
-// cc.Scheduler
-cc.Scheduler.prototype.scheduleUpdate = cc.Scheduler.prototype.scheduleUpdateForTarget;
-
-// cc.Scale9Sprite
-cc.Scale9Sprite.prototype._setBlendFunc = cc.Scale9Sprite.prototype.setBlendFunc;
-cc.Scale9Sprite.prototype.setBlendFunc = function(blendFunc, dst) {
- if (dst !== undefined) {
- blendFunc = {
- src : blendFunc,
- dst : dst
- };
- }
- this._setBlendFunc(blendFunc);
-};
-cc.Scale9Sprite.prototype._setContentSize = cc.Scale9Sprite.prototype.setContentSize;
-cc.Scale9Sprite.prototype.setContentSize = function(size, height){
- if (height !== undefined) {
- size = new cc.Size(size, height);
- }
- this._setContentSize(size);
-};
-cc.Scale9Sprite.prototype._setAnchorPoint = cc.Scale9Sprite.prototype.setAnchorPoint;
-cc.Scale9Sprite.prototype.setAnchorPoint = function(anchorPoint, y){
- if (y !== undefined) {
- anchorPoint = new cc.Vec2(anchorPoint, y);
- }
- this._setAnchorPoint(anchorPoint);
-};
diff --git a/moduleConfig.json b/moduleConfig.json
index 264eadfd43..6db9bc32a3 100644
--- a/moduleConfig.json
+++ b/moduleConfig.json
@@ -53,7 +53,6 @@
"cocos2d/core/platform/CCScreen.js",
"cocos2d/core/platform/CCVisibleRect.js",
- "cocos2d/core/support/CCPointExtension.js",
"cocos2d/core/support/CCVertex.js",
"cocos2d/core/support/TransformUtils.js",
"cocos2d/core/event-manager/CCTouch.js",
diff --git a/test/qunit/assets/library/19/19851210.json b/test/qunit/assets/library/19/19851210.json
deleted file mode 100644
index 27bdd7677c..0000000000
--- a/test/qunit/assets/library/19/19851210.json
+++ /dev/null
@@ -1,71 +0,0 @@
-[
- {
- "__type__": "cc.Prefab",
- "_name": "",
- "_objFlags": 0,
- "_rawFiles": null,
- "data": {
- "w": {
- "__id__": 1
- },
- "t": {
- "target": {
- "__id__": 3
- },
- "target2": null
- },
- "m": "TestScript",
- "c": [
- {
- "w": {
- "__id__": 3
- }
- }
- ]
- }
- },
- {
- "__type__": "TestWrapper",
- "_name": "",
- "_objFlags": 0,
- "_id": "",
- "_prefab": {
- "__id__": 2
- },
- "_serializeData": {
- "name": "",
- "scale": {
- "__type__": "cc.Vec2",
- "x": 123,
- "y": 432
- }
- }
- },
- {
- "__type__": "cc.PrefabInfo",
- "asset": null,
- "fileId": "1443343349665.678"
- },
- {
- "__type__": "TestWrapper",
- "_name": "",
- "_objFlags": 0,
- "_id": "",
- "_prefab": {
- "__id__": 4
- },
- "_serializeData": {
- "name": "",
- "scale": {
- "__type__": "cc.Vec2",
- "x": 22,
- "y": 11
- }
- }
- },
- {
- "__type__": "cc.PrefabInfo",
- "asset": null,
- "fileId": "1443343349665.5764"
- }
-]
\ No newline at end of file
diff --git a/test/qunit/unit/test-class.js b/test/qunit/unit/test-class.js
index 0c84d064a3..8d9db2d527 100644
--- a/test/qunit/unit/test-class.js
+++ b/test/qunit/unit/test-class.js
@@ -152,7 +152,8 @@ test('Inherit', function () {
properties: {
myName: {
default: 'doge',
- tooltip: 'String'
+ tooltip: 'String',
+ override: true
}
}
});
@@ -216,7 +217,10 @@ test('Inherit + constructor', function () {
name: 'cc.Dog',
extends: Animal,
properties: {
- myName: 'doge'
+ myName: {
+ default: 'doge',
+ override: true
+ },
}
});
var Husky = cc.Class({
@@ -346,7 +350,10 @@ test('isChildClassOf', function () {
name: 'cc.Dog',
extends: Animal,
properties: {
- name: 'doge'
+ name: {
+ default: 'doge',
+ override: true
+ }
}
});
var Husky = cc.Class({
@@ -542,7 +549,10 @@ test('mixins', function () {
extends: Dog,
mixins: [Mixin1, Mixin2],
properties: {
- p1: 'Defined by BigDog',
+ p1: {
+ default: 'Defined by BigDog',
+ override: true
+ },
p4: 'Defined by BigDog',
},
stop: function () {},
diff --git a/test/qunit/unit/test-component.js b/test/qunit/unit/test-component.js
index 080f117ce5..f2a22b025d 100644
--- a/test/qunit/unit/test-component.js
+++ b/test/qunit/unit/test-component.js
@@ -19,6 +19,39 @@ test('Inheritance of editor properties', function () {
strictEqual(child._playOnFocus, true, 'should inherit playOnFocus from base component');
});
+test('_isOnLoadCalled', function () {
+ var Comp = cc.Class({
+ extends: cc.Component,
+ onLoad: function () {
+ this.updateSprite();
+ },
+ updateSprite: function () {
+ equal(!!this._isOnLoadCalled, false, 'it should be false during onLoad');
+ },
+ });
+
+ var node = new cc.Node();
+ cc.director.getScene().addChild(node);
+ var comp = node.addComponent(Comp);
+
+ equal(!!comp._isOnLoadCalled, true, 'it should be true after onLoad');
+});
+
+test('should not cause an infinite loops if re-activated in onLoad', function () {
+ var Comp = cc.Class({
+ extends: cc.Component,
+ onLoad: function () {
+ this.node.active = false;
+ this.node.active = true;
+ }
+ });
+
+ var node = new cc.Node();
+ cc.director.getScene().addChild(node);
+ var comp = node.addComponent(Comp);
+ ok('done');
+});
+
//test('should not call lifecycle methods if not executeInEditMode', function () {
// var Comp = cc.Class({
// extends: CallbackTester,
diff --git a/test/qunit/unit/test-load-scene.js b/test/qunit/unit/test-load-scene.js
index cee4105b64..8810b8f68b 100644
--- a/test/qunit/unit/test-load-scene.js
+++ b/test/qunit/unit/test-load-scene.js
@@ -51,3 +51,45 @@
ok(cc.engine.getInstanceById(root1.uuid) === root1, 'should register uuid to engine after scene launch');
});
})();
+
+module('load scene', SetupEngine);
+
+test('persist node with dynamic scene', function () {
+ var oldScene = new cc.Scene();
+ cc.director.runScene(oldScene);
+
+ var globalNode = new cc.Node();
+ globalNode.parent = oldScene;
+ var childNode = new cc.Node();
+ childNode.parent = globalNode;
+
+ cc.game.addPersistRootNode(globalNode);
+
+ var newScene = new cc.Scene();
+ cc.director.runScene(newScene);
+
+ ok(globalNode.parent === newScene, 'persist node should not be destoryed automatically when loading a new scene');
+});
+
+(function () {
+ if (!TestEditorExtends) {
+ return;
+ }
+ test('persist node with loaded scene', function () {
+ var oldScene = new cc.Scene();
+ cc.director.runScene(oldScene);
+
+ var globalNode = new cc.Node();
+ globalNode.parent = oldScene;
+ var childNode = new cc.Node();
+ childNode.parent = globalNode;
+
+ cc.game.addPersistRootNode(globalNode);
+
+ var newScene = cc.deserialize(Editor.serialize(new cc.Scene(), {stringify: false}));
+
+ cc.director.runScene(newScene);
+
+ ok(globalNode.parent === newScene, 'persist node should not be destoryed automatically when loading a new scene');
+ });
+})();
diff --git a/test/qunit/unit/test-prefab.js b/test/qunit/unit/test-prefab.js
index e8e782b45f..64c1ef5ae5 100644
--- a/test/qunit/unit/test-prefab.js
+++ b/test/qunit/unit/test-prefab.js
@@ -139,10 +139,10 @@
asyncTest('revert prefab', function () {
// stub
- var restore = cc.loader.loadJson;
- cc.loader.loadJson = function (url, callback) {
+ var restore = cc.loader.loadTxt;
+ cc.loader.loadTxt = function (url, callback) {
if (url.endsWith(UUID + '.json')) {
- callback(null, prefabJson);
+ callback(null, JSON.stringify(prefabJson));
}
else {
restore(url, callback);
@@ -166,7 +166,7 @@
newNode2.setSiblingIndex(0);
Editor.PrefabUtils.revertPrefab(testNode, function () {
- cc.loader.loadJson = restore;
+ cc.loader.loadTxt = restore;
ok(testNode.getScaleX() === 123 && testNode.getScaleY() === 432, 'Revert property of the parent node');
ok(testNode.getComponent(TestScript).constructor === TestScript, 'Restore removed component');
var c = testNode.children[0];
diff --git a/test/visual-tests/main.js b/test/visual-tests/main.js
index ac90bf8cb6..789dc19e82 100644
--- a/test/visual-tests/main.js
+++ b/test/visual-tests/main.js
@@ -94,6 +94,22 @@ cc.game.run({
"renderMode" : 0,
"jsList" : [
+ '../../cocos2d/core/base-nodes/CCAtlasNode.js',
+ '../../cocos2d/core/base-nodes/CCAtlasNodeCanvasRenderCmd.js',
+ '../../cocos2d/core/base-nodes/CCAtlasNodeWebGLRenderCmd.js',
+
+ "../../cocos2d/core/labelttf/LabelTTFPropertyDefine.js",
+ "../../cocos2d/core/labelttf/CCLabelTTF.js",
+ "../../cocos2d/core/labelttf/CCLabelTTFCanvasRenderCmd.js",
+ "../../cocos2d/core/labelttf/CCLabelTTFWebGLRenderCmd.js",
+
+ "../../cocos2d/labels/CCLabelAtlas.js",
+ "../../cocos2d/labels/CCLabelAtlasCanvasRenderCmd.js",
+ "../../cocos2d/labels/CCLabelAtlasWebGLRenderCmd.js",
+ "../../cocos2d/labels/CCLabelBMFont.js",
+ "../../cocos2d/labels/CCLabelBMFontCanvasRenderCmd.js",
+ "../../cocos2d/labels/CCLabelBMFontWebGLRenderCmd.js",
+
"src/BaseTestLayer/BaseTestLayer.js",
"src/tests_resources.js",
@@ -135,28 +151,6 @@ cc.game.run({
"src/ExtensionsTest/NetworkTest/WebSocketTest.js",
"src/ExtensionsTest/NetworkTest/SocketIOTest.js",
- "src/GUITest/UIScene.js",
- "src/GUITest/UIButtonTest/UIButtonTest.js",
- "src/GUITest/UICheckBoxTest/UICheckBoxTest.js",
- "src/GUITest/UIFocusTest/UIFocusTest.js",
- "src/GUITest/UIImageViewTest/UIImageViewTest.js",
- "src/GUITest/UILabelAtlasTest/UILabelAtlasTest.js",
- "src/GUITest/UILabelBMFontTest/UILabelBMFontTest.js",
- "src/GUITest/UILabelTest/UILabelTest.js",
- "src/GUITest/UILayoutTest/UILayoutTest.js",
- "src/GUITest/UIListViewTest/UIListViewTest.js",
- "src/GUITest/UILoadingBarTest/UILoadingBarTest.js",
- "src/GUITest/UINodeContainerTest/UINodeContainerTest.js",
- "src/GUITest/UIPageViewTest/UIPageViewTest.js",
- "src/GUITest/UISceneManager.js",
- "src/GUITest/UIScrollViewTest/UIScrollViewTest.js",
- "src/GUITest/UISliderTest/UISliderTest.js",
- "src/GUITest/UITextFieldTest/UITextFieldTest.js",
- "src/GUITest/UIRichTextTest/UIRichTextTest.js",
- "src/GUITest/UITextTest/UITextTest.js",
- "src/GUITest/UIWebViewTest/UIWebViewTest.js",
- "src/GUITest/UIS9NinePatchTest/UIS9NinePatchTest.js",
-
"src/XHRTest/XHRTest.js",
"src/XHRTest/XHRArrayBufferTest.js",
@@ -164,11 +158,6 @@ cc.game.run({
"src/SpritePolygonTest/SpritePolygonTest.js",
- "src/NativeTest/NativeTest.js",
- "src/NativeTest/FileUtils/FileUtilsTest.js",
- "src/NativeTest/JSBExtendTest.js",
- "src/NativeTest/AudioEngineTest.js",
-
"src/NodeEventTest/NodeEventTest.js"
]
}, function(){
diff --git a/test/visual-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js b/test/visual-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js
index 29864eaac7..d6f267b308 100644
--- a/test/visual-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js
+++ b/test/visual-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js
@@ -111,11 +111,11 @@ var S9CreationTest = S9SpriteTestDemo.extend({
var x = winSize.width;
var y = 0 + (winSize.height/2);
- var s9sprite1 = cc.Scale9Sprite.create("Images/blocks.png");
+ var s9sprite1 = new cc.Scale9Sprite("Images/blocks.png");
- var s9sprite2 = cc.Scale9Sprite.create("blocks9.png");
+ var s9sprite2 = new cc.Scale9Sprite("blocks9.png");
- var s9sprite3 = cc.Scale9Sprite.create("blocks9r.png");
+ var s9sprite3 = new cc.Scale9Sprite("blocks9r.png");
s9sprite1.setContentSize(cc.size(150,150));
s9sprite2.setContentSize(cc.size(150,150));
@@ -143,9 +143,9 @@ var S9RenderingTypeTest = S9SpriteTestDemo.extend({
var x = winSize.width;
var y = 0 + (winSize.height/2);
- var s9sprite1 = cc.Scale9Sprite.create("Images/blocks9.png");
+ var s9sprite1 = new cc.Scale9Sprite("res/Images/blocks9.png");
- var s9sprite2 = cc.Scale9Sprite.create("Images/blocks9.png");
+ var s9sprite2 = new cc.Scale9Sprite("res/Images/blocks9.png");
s9sprite1.setInsetLeft(20);
s9sprite1.setInsetRight(20);
s9sprite1.setInsetTop(30);
@@ -159,7 +159,7 @@ var S9RenderingTypeTest = S9SpriteTestDemo.extend({
s9sprite1.setContentSize(cc.size(150,150));
s9sprite2.setContentSize(cc.size(150,150));
- s9sprite2.setRenderingType(ccui.Scale9Sprite.RenderingType.SIMPLE);
+ s9sprite2.setRenderingType(cc.Scale9Sprite.RenderingType.SIMPLE);
s9sprite1.x = x/4; s9sprite1.y = y;
@@ -182,14 +182,14 @@ var S9StateTest = S9SpriteTestDemo.extend({
var x = winSize.width;
var y = 0 + (winSize.height/2);
- var s9sprite1 = cc.Scale9Sprite.create("Images/blocks9.png");
+ var s9sprite1 = new cc.Scale9Sprite("res/Images/blocks9.png");
- var s9sprite2 = cc.Scale9Sprite.create("Images/blocks9.png");
+ var s9sprite2 = new cc.Scale9Sprite("res/Images/blocks9.png");
s9sprite1.setContentSize(cc.size(150,150));
s9sprite2.setContentSize(cc.size(150,150));
- s9sprite2.setState(ccui.Scale9Sprite.state.GRAY);
+ s9sprite2.setState(cc.Scale9Sprite.state.GRAY);
s9sprite1.x = x/4; s9sprite1.y = y;
@@ -213,7 +213,7 @@ var S9Actiontest = S9SpriteTestDemo.extend({
var x = winSize.width ;
var y = 0 + (winSize.height / 2);
- var s9sprite1 = cc.Scale9Sprite.create("Images/blocks9.png");
+ var s9sprite1 = new cc.Scale9Sprite("res/Images/blocks9.png");
s9sprite1.setContentSize(cc.size(150,150));
s9sprite1.x = x/4; s9sprite1.y = y;
@@ -239,7 +239,7 @@ var S9ChangeFiletest = S9SpriteTestDemo.extend({
var x = winSize.width ;
var y = 0 + (winSize.height / 2);
- _s9sprite1 = cc.Scale9Sprite.create("Images/blocks9.png");
+ _s9sprite1 = new cc.Scale9Sprite("res/Images/blocks9.png");
_s9sprite1.setContentSize(cc.size(300,200));
_s9sprite1.x = x/2; _s9sprite1.y = y;
@@ -252,10 +252,10 @@ var S9ChangeFiletest = S9SpriteTestDemo.extend({
_s9sprite1.runAction(cc.Sequence.create(actionArray));
},
changeFile1: function() {
- this.changeFile("Images/btn-highscores-normal.png");
+ this.changeFile("res/Images/btn-highscores-normal.png");
},
changeFile2: function() {
- this.changeFile("Images/blocks9.png");
+ this.changeFile("res/Images/blocks9.png");
},
changeFile: function(file) {
console.log("I'am going to change a new file");
@@ -281,9 +281,9 @@ var S9ChangePreferredSizeTest = S9SpriteTestDemo.extend({
var x = winSize.width;
var y = 0 + (winSize.height/2);
- this._s9sprite1 = cc.Scale9Sprite.create("Images/blocks9.png");
+ this._s9sprite1 = new cc.Scale9Sprite("res/Images/blocks9.png");
- this._s9sprite2 = cc.Scale9Sprite.create("Images/blocks9.png");
+ this._s9sprite2 = new cc.Scale9Sprite("res/Images/blocks9.png");
var s9sprite1 = this._s9sprite1;
var s9sprite2 = this._s9sprite2;
s9sprite1.setContentSize(cc.size(96,96));
@@ -301,7 +301,7 @@ var S9ChangePreferredSizeTest = S9SpriteTestDemo.extend({
this.scheduleUpdate();
- s9sprite2.setRenderingType(ccui.Scale9Sprite.RenderingType.SIMPLE);
+ s9sprite2.setRenderingType(cc.Scale9Sprite.RenderingType.SIMPLE);
s9sprite1.x = x/4; s9sprite1.y = y;
@@ -335,9 +335,9 @@ var S9ChangeCapInsetsTest = S9SpriteTestDemo.extend({
var x = winSize.width;
var y = 0 + (winSize.height/2);
- this._s9sprite1 = cc.Scale9Sprite.create("Images/blocks9.png");
+ this._s9sprite1 = new cc.Scale9Sprite("res/Images/blocks9.png");
- this._s9sprite2 = cc.Scale9Sprite.create("Images/blocks9.png");
+ this._s9sprite2 = new cc.Scale9Sprite("res/Images/blocks9.png");
var s9sprite1 = this._s9sprite1;
var s9sprite2 = this._s9sprite2;
s9sprite1.setContentSize(cc.size(150,150));
@@ -393,9 +393,9 @@ var S9ChangeColorOpacityTest = S9SpriteTestDemo.extend({
var x = winSize.width;
var y = 0 + (winSize.height/2);
- this._s9sprite1 = cc.Scale9Sprite.create("Images/blocks9.png");
+ this._s9sprite1 = new cc.Scale9Sprite("res/Images/blocks9.png");
- this._s9sprite2 = cc.Scale9Sprite.create("Images/blocks9.png");
+ this._s9sprite2 = new cc.Scale9Sprite("res/Images/blocks9.png");
var s9sprite1 = this._s9sprite1;
var s9sprite2 = this._s9sprite2;
s9sprite1.setContentSize(cc.size(150,150));
diff --git a/test/visual-tests/src/SchedulerTest/SchedulerTest.js b/test/visual-tests/src/SchedulerTest/SchedulerTest.js
index 165a60e997..69104d3fab 100644
--- a/test/visual-tests/src/SchedulerTest/SchedulerTest.js
+++ b/test/visual-tests/src/SchedulerTest/SchedulerTest.js
@@ -710,7 +710,7 @@ var SchedulerTestScene = TestScene.extend({
//
var arrayOfSchedulerTest = [
- SchedulerTimeScale,
+ // SchedulerTimeScale,
SchedulerAutoremove,
SchedulerPauseResume,
SchedulerUnscheduleAll,
diff --git a/test/visual-tests/src/TextureCacheTest/TextureCacheTest.js b/test/visual-tests/src/TextureCacheTest/TextureCacheTest.js
index f3701f07b8..e650912944 100644
--- a/test/visual-tests/src/TextureCacheTest/TextureCacheTest.js
+++ b/test/visual-tests/src/TextureCacheTest/TextureCacheTest.js
@@ -163,8 +163,8 @@ var TextureCacheTest = TextureCacheTestBase.extend({
texCache.addImageAsync("Images/grossini_dance_12.png", this.loadingCallBack, this);
texCache.addImageAsync("Images/grossini_dance_13.png", this.loadingCallBack, this);
texCache.addImageAsync("Images/grossini_dance_14.png", this.loadingCallBack, this);
- texCache.addImageAsync("Images/background1.png", this.loadingCallBack, this);
- texCache.addImageAsync("Images/background2.png", this.loadingCallBack, this);
+ texCache.addImageAsync("res/Images/background1.png", this.loadingCallBack, this);
+ texCache.addImageAsync("res/Images/background2.png", this.loadingCallBack, this);
texCache.addImageAsync("Images/background3.png", this.loadingCallBack, this);
texCache.addImageAsync("Images/blocks.png", this.loadingCallBack, this);
},
@@ -194,8 +194,8 @@ var TextureCacheTest = TextureCacheTestBase.extend({
var s15 = new _ccsg.Sprite("Images/grossini_dance_14.png");
// just loading textures to slow down
- var s16 = new _ccsg.Sprite("Images/background1.png");
- var s17 = new _ccsg.Sprite("Images/background2.png");
+ var s16 = new _ccsg.Sprite("res/Images/background1.png");
+ var s17 = new _ccsg.Sprite("res/Images/background2.png");
var s18 = new _ccsg.Sprite("Images/background3.png");
var s19 = new _ccsg.Sprite("Images/blocks.png");
diff --git a/test/visual-tests/src/tests-main.js b/test/visual-tests/src/tests-main.js
index e39f88edaf..da5026e1ca 100644
--- a/test/visual-tests/src/tests-main.js
+++ b/test/visual-tests/src/tests-main.js
@@ -266,7 +266,7 @@ var testNames = [
}
},
{
- title:"CocosDenshion Test",
+ title:"AudioEngine Test",
resource:g_cocosdeshion,
platforms: PLATFORM_ALL,
linksrc:"src/CocosDenshionTest/CocosDenshionTest.js",
@@ -317,23 +317,6 @@ var testNames = [
return new ExtensionsTestScene();
}
},
- {
- title:"Native Test",
- platforms: PLATFORM_JSB,
- linksrc:"src/NativeTest/NativeTest.js",
- testScene:function () {
- return new NativeTestScene();
- }
- },
- {
- title:"UI Test",
- resource:g_ui,
- platforms: PLATFORM_ALL,
- linksrc:"",
- testScene:function () {
- return new GUITestScene();
- }
- },
{
title:"Interval Test",
platforms: PLATFORM_ALL,
@@ -342,15 +325,6 @@ var testNames = [
return new IntervalTestScene();
}
},
- {
- title:"Label Test",
- resource:g_label,
- platforms: PLATFORM_ALL,
- linksrc:"src/LabelTest/LabelTest.js",
- testScene:function () {
- return new LabelTestScene();
- }
- },
{
title:"Layer Test",
platforms: PLATFORM_ALL,
diff --git a/test/visual-tests/src/tests_resources.js b/test/visual-tests/src/tests_resources.js
index 11f2da0751..43adc2a1c1 100644
--- a/test/visual-tests/src/tests_resources.js
+++ b/test/visual-tests/src/tests_resources.js
@@ -28,8 +28,8 @@ var s_pathF1 = "Images/f1.png";
var s_pathF2 = "Images/f2.png";
var s_pathBlock = "Images/blocks.png";
var s_back = "Images/background.png";
-var s_back1 = "Images/background1.png";
-var s_back2 = "Images/background2.png";
+var s_back1 = "res/Images/background1.png";
+var s_back2 = "res/Images/background2.png";
var s_back3 = "Images/background3.png";
var s_stars1 = "Images/stars.png";
var s_stars2 = "Images/stars2.png";
@@ -112,7 +112,7 @@ var s_testEasing0_png = "ccs-res/armature/testEasing0.png";
var s_s9s_blocks9 = "Images/blocks9ss.png";
var s_s9s_blocks9_plist = "Images/blocks9ss.plist";
-var s_blocks9 = "Images/blocks9.png";
+var s_blocks9 = "res/Images/blocks9.png";
var s_s9s_ui = "Images/ui.png";
var s_s9s_ui_plist = "Images/ui.plist";
diff --git a/tools/XmlCheck.js b/tools/XmlCheck.js
deleted file mode 100644
index 159933cd37..0000000000
--- a/tools/XmlCheck.js
+++ /dev/null
@@ -1,143 +0,0 @@
-const fs = require("fs");
-const path = require("path");
-const modules = JSON.parse(fs.readFileSync("../moduleConfig.json"));
-
-var contains = [
- "../cocos2d",
- "../extensions",
- "../external",
- "../Base64Images.js",
- "../CCBoot.js",
- "../CCDebugger.js"
-];
-(function(){
- var i = 0;
- function read(name){
- if(fs.existsSync(name)){
- var stat = fs.statSync(name);
- if(stat.isDirectory()){
- contains.splice(i--, 1);
- var fileList = fs.readdirSync(name);
- for(var n=0; n((.|\r\n|\r|\n)*?)\<\/sources/g, function(a, b){
- a.replace(/file name\=\"(.*)\"\/\>/g, function(c, d){
- arr[index] && arr[index].push("../" + d);
- });
- index++;
- });
-})();
-console.log(" The number of files in the XML file : %s", xmlFile.length);
-
-contains = contains.map(function(a){
- return path.normalize(a);
-});
-moduleFile = moduleFile.map(function(a){
- return path.normalize(a);
-});
-xmlFile = xmlFile.map(function(a){
- return path.normalize(a);
-});
-xmlFile2 = xmlFile2.map(function(a){
- return path.normalize(a);
-});
-
-console.log("\x1B[0m\x1B[33m");
-console.log(" warn : moduleConfig missing...");
-contains.forEach(function(a){
- if(!moduleFile.some(function(b){return b==a}))
- console.log(" " + a);
-});
-
-
-console.log("\x1B[0m\x1B[92m");
-console.log(" warn : engine dir missing...");
-moduleFile.forEach(function(a){
- if(!contains.some(function(b){return b==a}))
- console.log(" " + a);
-});
-
-
-console.log("\x1B[0m\x1B[96m");
-console.log(" warn : xml(all) file missing...");
-contains.forEach(function(a){
- if(!xmlFile.some(function(b){return b==a}))
- console.log(" " + a);
-});
-
-
-console.log("\x1B[0m\x1B[91m");
-console.log(" warn : xml(all) redundant files...");
-xmlFile.forEach(function(a){
- if(!contains.some(function(b){return b==a}))
- console.log(" " + a);
-});
-
-
-console.log("\x1B[0m\x1B[94m");
-console.log(" warn : xml(core) maybe missing files...");
-xmlFile2.forEach(function(a){
- var basename = path.basename(a);
- basename = basename.substr(0, basename.indexOf("."));
- contains.forEach(function(b){
- if(b.indexOf(basename) > -1 && a != b){
- if(
- b.indexOf("extensions") == -1 &&
- !xmlFile2.some(function(c){return b == c;})
- )
- console.log(" " + b);
- }
- });
-});
-
-
-console.log("\x1B[0m\x1B[35m");
-console.log(" warn : xml(core) redundant files...");
-xmlFile2.forEach(function(a){
- if(!contains.some(function(b){return b==a}))
- console.log(" " + a);
-});
-console.log("\x1B[0m");
\ No newline at end of file
diff --git a/tools/compiler/compiler.jar b/tools/compiler/compiler.jar
deleted file mode 100644
index e2338676d5..0000000000
Binary files a/tools/compiler/compiler.jar and /dev/null differ
diff --git a/tools/core4cc.js b/tools/core4cc.js
deleted file mode 100644
index 3aea7552dc..0000000000
--- a/tools/core4cc.js
+++ /dev/null
@@ -1,245 +0,0 @@
-var fs = require("fs");
-var path = require("path");
-var exec = require('child_process').exec;
-var spawn = require('child_process').spawn;
-var url = require('url');
-
-var core4cc = {};
-module.exports = core4cc;
-
-/**
- * Desc:merge js code from client to server.
- * @param src src path
- * @param targetDir target path
- * @param requireArr dependencies
- * @param name
- */
-core4cc.trans2Module = function(src, targetDir, requireArr, name){
- if(!fs.existsSync(targetDir)) fs.mkdirSync(targetDir);
- var srcBaseName = path.basename(src);
- name = name || path.basename(src, ".js");
- var content = fs.readFileSync(src).toString();
- var requireStr = "";
- for(var i = 0, li = requireArr.length; i < li; ++i){
- var strs = requireArr[i].split("->");
- requireStr = requireStr + "var " + strs[0] + " = require('" + strs[1] + "');\r\n";
- }
- fs.writeFileSync(targetDir + srcBaseName, requireStr + content + "\r\nmodule.exports = " + name + ";");
-};
-
-/**
- * Desc:merge js arr to one
- * @param srcs
- * @param target
- * @param requireArr
- * @param name
- */
-core4cc.merge2Module = function(srcs, target, requireArr, name){
- var targetDir = path.dirname(target);
- if(!fs.existsSync(targetDir)) fs.mkdirSync(targetDir);
- var content = "";
- for(var i = 0, li = srcs.length; i < li; ++i){
- content += fs.readFileSync(srcs[i]).toString() + "\r\n";
- }
- var requireStr = "";
- for(var i = 0, li = requireArr.length; i < li; ++i){
- var strs = requireArr[i].split("->");
- requireStr = requireStr + "var " + strs[0] + " = require('" + strs[1] + "');\r\n";
- }
- fs.writeFileSync(target, requireStr + content + "\r\nmodule.exports = " + name + ";");
-};
-
-/**
- * dESC: Get key name by the file name.
- * @param name
- * @returns {String}
- */
-core4cc.getKeyName = function(name){
- var key = name.replace(/[.]/g, "_");
- key = key.replace(/[\-\(\)]/g, "_");
- var r = key.match(/^[0-9]/);
- if(r != null) key = "_" + key;
- return key.replace(/\s/g, "");
-};
-/**
- * Desc: Returns array for dependencies.
- * @param temp
- * @returns {Array}
- * @private
- */
-core4cc.getDependencies = function(temp){
- var dependencies = [];
- for(var key in temp){
- dependencies.push(key);
- };
- return dependencies;
-};
-
-/**
- * Desc: unzip
- * @param srcZip
- * @param targetDir
- * @param cb
- */
-core4cc.unzip = function(srcZip, targetDir, cb){
- var execCode = "unzip " + srcZip + " -d " + targetDir;
- exec(execCode, function(err, data, info){
- if(err) return cb(err);
- else cb(null);
- });
-};
-
-
-
-/**
- * Desc: Download resources.
- * @param downLoadDir
- * @param fileUrl
- * @param cb
- */
-core4cc.download = function(downLoadDir, fileUrl, cb) {
- // extract the file name
- var fileName = url.parse(fileUrl).pathname.split('/').pop();
- // create an instance of writable stream
- var file = fs.createWriteStream(path.join(downLoadDir, fileName));
- // execute curl using child_process' spawn function
- var curl = spawn('curl', [fileUrl]);
- // add a 'data' event listener for the spawn instance
- curl.stdout.on('data', function(data) { file.write(data); });
- // add an 'end' event listener to close the writeable stream
- curl.stdout.on('end', function(data) {
- file.end();
- console.log(fileName + ' downloaded to ' + downLoadDir);
- cb(null);
- });
- // when the spawn child process exits, check if there were any errors and close the writeable stream
- curl.on('exit', function(code) {
- if (code != 0) {
- console.error('Failed: ' + code);
- cb("error")
- }
- });
-};
-
-/**
- * Desc: Remove dir recursively.
- * @param filePath
- * @param ignores
- */
-core4cc.rmdirSyncRecursive = function(filePath, ignores) {
- var files = [];
- if( fs.existsSync(filePath) ) {
- if(ignores && ignores.length > 0 && ignores.indexOf(filePath) >= 0) return;
- if(!fs.statSync(filePath).isDirectory()) return fs.unlinkSync(filePath);
- files = fs.readdirSync(filePath);
- for(var i = 0, li = files.length; i < li; i++){
- var curPath = path.join(filePath, files[i]);
- core4cc.rmdirSyncRecursive(curPath, ignores); // recurse
- }
- files = fs.readdirSync(filePath);//read again
- if(files.length == 0) fs.rmdirSync(filePath);
- }
-};
-
-/**
- * Desc: Create dir recursively.
- * @param arr
- * @param index
- * @param cb
- * @returns {*}
- */
-core4cc.mkdirRecursive = function(arr, index, cb){
- if(index >= arr.length) cb();
- var dir = path.join(process.cwd(), arr.slice(0, index +1).join(path.sep));
- if(fs.existsSync(dir)) return core4cc.mkdirRecursive(arr, index+1, cb);
- fs.mkdir(dir, function(){
- core4cc.mkdirRecursive(arr, index+1, cb);
- });
-}
-/**
- * Desc: create dir sync recursively.
- * @param targetPath
- */
-core4cc.mkdirSyncRecursive = function(targetPath){
- if(targetPath == null || targetPath == "") return;
- targetPath = core4cc.isAbsolute(targetPath) ? path.normalize(targetPath) : path.join(process.cwd(), targetPath);
- if(fs.existsSync(targetPath)) return;
-
- var arr = targetPath.split(path.sep);
- var index = arr.length - 1;
- var tempStr = arr[index];
- while(tempStr == "" && arr.length > 0){
- index--;
- tempStr = arr[index];
- }
- if(tempStr == "") return;
- var newPath = targetPath.substring(0, targetPath.length - tempStr.length - 1);
- if(!fs.existsSync(newPath)) core4cc.mkdirSyncRecursive(newPath);
- fs.mkdirSync(targetPath);
-}
-/**
- * Desc: Returns true if the filePath is absolute.
- * @param filePath
- * @returns {boolean}
- */
-core4cc.isAbsolute = function(filePath){
- filePath = path.normalize(filePath);
- if(filePath.substring(0, 1) == "/") return true;
- if(filePath.search(/[\w]+:/) == 0) return true;
- return false;
-};
-
-/**
- * Desc: Copy files in srcPath to targetPath, then replace info by config.
- * @param srcPath
- * @param targetPath
- * @param handler
- * @private
- */
-core4cc.copyFiles = function(srcPath, targetPath, handler){
- if(!fs.statSync(srcPath).isDirectory()) return fs.writeFileSync(targetPath, fs.readFileSync(srcPath));//copy if it`s a file
-
- if(!fs.existsSync(targetPath)) fs.mkdirSync(targetPath);
- var files = fs.readdirSync(srcPath);
- for(var i = 0, li = files.length; i < li; i++){
- var file = files[i];
- if(fs.statSync(path.join(srcPath, file)).isDirectory()){//make dir if it`s a dir
- var dir = path.join(targetPath, file, "./");
- if(!fs.existsSync(dir)) fs.mkdirSync(dir);
- core4cc.copyFiles(path.join(srcPath, file + "/"), dir, handler);//goes on
- }else{
- var filePath = path.join(targetPath, file);
- fs.writeFileSync(filePath, fs.readFileSync(path.join(srcPath, file)));//copy if it`s a file
- if(handler) {
- handler.fmt(filePath);
- }
- }
- }
-}
-
-/**
- * Desc: Get string for command.
- * e.g. aaaa ---> aaaa
- * "a a" ---> a a
- * @param str
- * @returns {*}
- */
-core4cc.getStr4Cmd = function(str){
- if(!str) return null;
- if(str.length < 2) return str;
- return str.substring(0, 1) == '"' && str.substring(str.length - 1) == '"' ? str.substring(1, str.length - 1) : str;
-}
-/**
- * Desc: Merge data by default value
- * @param data
- * @param defData default value
- * @returns {{}|*}
- */
-core4cc.mergeData = function(data, defData){
- data = data || {};
- if(defData == null) return data;;
- for (var key in defData) {
- if(data[key] == null && defData[key] != null) data[key] = defData[key];
- }
- return data;
-}
diff --git a/tools/genBuildXml.js b/tools/genBuildXml.js
deleted file mode 100644
index e16ff3ef7c..0000000000
--- a/tools/genBuildXml.js
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * Put the `tools` in the root of your project, then run this script with nodejs.
- * @type {exports|*}
- */
-
-var fs = require("fs");
-var path = require("path");
-
-
-module.exports = function(projectDir, projectJson, buildOpt){
- var engineDir = projectJson.engineDir || "frameworks/cocos2d-html5";
- var realEngineDir = path.join(projectDir, engineDir);
- var realPublishDir = path.join(projectDir, "publish/html5");
- var realToolsDir = path.dirname(__filename);
- var moduleConfig = require(path.join(realEngineDir, "moduleConfig.json"));
- var ccModuleMap = moduleConfig.module;
- var modules = projectJson.modules || ["core"];
- var renderMode = projectJson.renderMode || 0;
- var mainJs = projectJson.main || "main.js";
-
-
- var ccJsList = [moduleConfig.bootFile];
- var userJsList = projectJson.jsList || [];
-
- if(renderMode != 1 && modules.indexOf("base4webgl") < 0){
- modules.splice(0, 0, "base4webgl");
- }
-
-
- //cache for js and module that has added into jsList to be loaded.
- var _jsAddedCache = {};
- function _getJsListOfModule(moduleMap, moduleName){
- var jsAddedCache = _jsAddedCache;
- if(jsAddedCache[moduleName]) return null;
- jsAddedCache[moduleName] = true;
- var jsList = [];
- var tempList = moduleMap[moduleName];
- if(!tempList) throw new Error("can not find module [" + moduleName + "]");
- for(var i = 0, li = tempList.length; i < li; i++){
- var item = tempList[i];
- if(jsAddedCache[item]) continue;
- var extname = path.extname(item);
- if(!extname) {
- var arr = _getJsListOfModule(moduleMap, item);
- if(arr) jsList = jsList.concat(arr);
- }else if(extname.toLowerCase() == ".js") jsList.push(item);
- jsAddedCache[item] = true;
- }
- return jsList;
- };
-
-
-
- for(var i = 0, li = modules.length; i < li; i++){
- var item = modules[i];
- var arr = _getJsListOfModule(ccModuleMap, item, "");
- if(arr) ccJsList = ccJsList.concat(arr);
- }
-
- var externalList = [];
- function getFileArrStr(jsList){
- var str = "";
- for(var i = 0, li = jsList.length; i < li; i++){
- if(/^external/.test(jsList[i]) && !/Plugin/.test(jsList[i])){
- externalList.push(jsList[i]);
- }else{
- str += ' ';
- if(i < li - 1) str += '\r\n';
- }
- }
- return str;
- }
-
- userJsList.push(mainJs);
-
- var buildContent = fs.readFileSync(path.join(realToolsDir, "template/build.xml")).toString();
- buildContent = buildContent.replace(/%projectDir%/gi, projectDir);
- buildContent = buildContent.replace(/%engineDir%/gi, realEngineDir);
- buildContent = buildContent.replace(/%publishDir%/gi, realPublishDir);
- buildContent = buildContent.replace(/%outputFileName%/gi, buildOpt.outputFileName);
- buildContent = buildContent.replace(/%toolsDir%/gi, realToolsDir);
- buildContent = buildContent.replace(/%compilationLevel%/gi, buildOpt.compilationLevel);
- buildContent = buildContent.replace(/%sourceMapCfg%/gi, buildOpt.sourceMapOpened ? 'sourceMapOutputFile="' + path.join(realPublishDir, "sourcemap") + '" sourceMapFormat="V3"' : "");
- buildContent = buildContent.replace(/%ccJsList%/gi, getFileArrStr(ccJsList));
- buildContent = buildContent.replace(/%userJsList%/gi, getFileArrStr(userJsList));
- fs.writeFileSync(path.join(realPublishDir, "build.xml"), buildContent);
-
- return externalList;
-};
diff --git a/tools/publish.js b/tools/publish.js
deleted file mode 100644
index 4b28867133..0000000000
--- a/tools/publish.js
+++ /dev/null
@@ -1,72 +0,0 @@
-var exec = require("child_process").exec;
-var fs = require("fs");
-var path = require("path");
-var core4cc = require("./core4cc");
-console.log("Publishing...");
-
-var projectDir = path.join(__dirname, "../");
-
-var projectJson = require(path.join(projectDir, "project.json"));
-var engineDir = path.join(projectJson.engineDir || "frameworks/cocos2d-html5", "/");
-var realEngineDir = path.join(projectDir, engineDir, "/");
-
-var realPublishDir = path.join(projectDir, "publish/html5");
-
-var buildOpt = {
- outputFileName : "game.min.js",
-// compilationLevel : "simple",
- compilationLevel : "advanced",
- sourceMapOpened : true
-};
-
-if(!fs.existsSync(realPublishDir)) core4cc.mkdirSyncRecursive(realPublishDir);
-
-var externalList = require("./genBuildXml")(projectDir, projectJson, buildOpt);
-
-var outputJsPath = path.join(realPublishDir, buildOpt.outputFileName);
-if(fs.existsSync(outputJsPath)) fs.unlinkSync(outputJsPath);
-
-exec("cd " + realPublishDir + " && ant", function(err, data, info){
- console.log(info);
- console.log(data);
- if(err) {
- console.error(err);
- console.log(err[0]);
- return console.log("Failed!")
- }
- var sourceMapPath = path.join(realPublishDir, "sourcemap");
- if(fs.existsSync(sourceMapPath)){
- var smContent = fs.readFileSync(sourceMapPath).toString();
- smContent = smContent.replace(new RegExp(path.join(projectDir, "/").replace(/\\/g, "\\\\\\\\") , "gi"), path.join(path.relative(realPublishDir, projectDir), "/"));
- smContent = smContent.replace(new RegExp(path.join(realEngineDir, "/").replace(/\\/g, "\\\\\\\\"), "gi"), path.join(path.relative(realPublishDir, realEngineDir), "/"));
- fs.writeFileSync(sourceMapPath, smContent);
- }
-
- delete projectJson.engineDir;
- delete projectJson.modules;
- delete projectJson.jsList;
- fs.writeFileSync(path.join(realPublishDir, "project.json"), JSON.stringify(projectJson, null, 4));
-
- var publishResDir = path.join(realPublishDir, "res");
- core4cc.rmdirSyncRecursive(publishResDir);
- core4cc.copyFiles(path.join(projectDir, "res"), publishResDir);
-
- var indexContent = fs.readFileSync(path.join(projectDir, "index.html")).toString();
- var externalScript = "";
- externalList.forEach(function(external){
- externalScript += "\n";
- });
- indexContent = indexContent.replace(/";
- });
- indexContent += externalScript;
- fs.writeFileSync(path.join(realPublishDir, "index.html"), indexContent);
- console.log("Finished!")
-});
\ No newline at end of file
diff --git a/tools/readme for tools.txt b/tools/readme for tools.txt
deleted file mode 100644
index c1273175d6..0000000000
--- a/tools/readme for tools.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Compiler:
-
-Default compiler is Google closure compiler. Please install Ant and Jre to build.
-The shell files and Closure Compiler which Ant needs are provided in tools folder and cocos2d folder.
-
-Reference wiki: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Closure_Compiler
-For more on Google closure: https://developers.google.com/closure/compiler
-