Merge pull request #178 from jareguo/master

remove unused files
This commit is contained in:
Jare Guo
2015-12-31 16:57:18 +08:00
15 changed files with 2 additions and 1899 deletions
-177
View File
@@ -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;
-250
View File
@@ -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;
-27
View File
@@ -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'],
];
-202
View File
@@ -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;
-182
View File
@@ -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;
@@ -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;
-44
View File
@@ -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;
@@ -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;
-171
View File
@@ -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;
-139
View File
@@ -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;
@@ -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;
-178
View File
@@ -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;
-245
View File
@@ -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;
+2
View File
@@ -388,6 +388,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.
@@ -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"
}
]