mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 16:52:43 +08:00
Merge branch 'v1.2' of github.com:cocos-creator/engine into v1.2
This commit is contained in:
@@ -236,9 +236,10 @@ var Component = cc.Class({
|
||||
name: 'cc.Component',
|
||||
extends: cc.Object,
|
||||
|
||||
ctor: (CC_EDITOR && window._Scene && _Scene.AssetsWatcher) ? function () {
|
||||
_Scene.AssetsWatcher.initComponent(this);
|
||||
|
||||
ctor: CC_EDITOR ? function () {
|
||||
if (window._Scene && _Scene.AssetsWatcher) {
|
||||
_Scene.AssetsWatcher.initComponent(this);
|
||||
}
|
||||
// Support for Scheduler
|
||||
this.__instanceId = cc.ClassManager.getNewInstanceId();
|
||||
} : function () {
|
||||
|
||||
@@ -103,7 +103,13 @@ var EventType = cc.Enum({
|
||||
* !#zh 滚动视图滚动滚动结束的时候发出的事件
|
||||
* @property {Number} AUTOSCROLL_ENDED
|
||||
*/
|
||||
AUTOSCROLL_ENDED : 9
|
||||
AUTOSCROLL_ENDED : 9,
|
||||
/**
|
||||
* !#en The event emmitted when user release the touch
|
||||
* !#zh 当用户松手的时候会发出一个事件
|
||||
* @property {Number} TOUCH_UP
|
||||
*/
|
||||
TOUCH_UP : 10
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -698,6 +704,8 @@ var ScrollView = cc.Class({
|
||||
},
|
||||
|
||||
_onMouseWheel: function(event) {
|
||||
if (!this.enabledInHierarchy) return;
|
||||
|
||||
var deltaMove = cc.p(0, 0);
|
||||
var wheelPrecision = 1.0 / 40;
|
||||
if(CC_JSB) {
|
||||
@@ -847,6 +855,8 @@ var ScrollView = cc.Class({
|
||||
|
||||
// touch event handler
|
||||
_onTouchBegan: function(event) {
|
||||
if (!this.enabledInHierarchy) return;
|
||||
|
||||
var touch = event.touch;
|
||||
if (this.content) {
|
||||
this._handlePressLogic(touch);
|
||||
@@ -855,6 +865,8 @@ var ScrollView = cc.Class({
|
||||
},
|
||||
|
||||
_onTouchMoved: function(event) {
|
||||
if (!this.enabledInHierarchy) return;
|
||||
|
||||
var touch = event.touch;
|
||||
if (this.content) {
|
||||
this._handleMoveLogic(touch);
|
||||
@@ -881,15 +893,20 @@ var ScrollView = cc.Class({
|
||||
},
|
||||
|
||||
_onTouchEnded: function(event) {
|
||||
if (!this.enabledInHierarchy) return;
|
||||
|
||||
var touch = event.touch;
|
||||
if (this.content) {
|
||||
this._handleReleaseLogic(touch);
|
||||
}
|
||||
this._dispatchEvent(EventType.TOUCH_UP);
|
||||
if (this._touchMoved) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
},
|
||||
_onTouchCancelled: function(event) {
|
||||
if (!this.enabledInHierarchy) return;
|
||||
|
||||
// Filte touch cancel event send from self
|
||||
if (!event.simulate) {
|
||||
var touch = event.touch;
|
||||
|
||||
@@ -163,10 +163,17 @@ var Sprite = cc.Class({
|
||||
return this._spriteFrame;
|
||||
},
|
||||
set: function (value, force) {
|
||||
if (this._spriteFrame === value) {
|
||||
return;
|
||||
}
|
||||
var lastSprite = this._spriteFrame;
|
||||
if (CC_EDITOR) {
|
||||
if (!force && ((lastSprite && lastSprite._uuid) === (value && value._uuid))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (lastSprite === value) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this._spriteFrame = value;
|
||||
this._applySpriteFrame(lastSprite);
|
||||
if (CC_EDITOR) {
|
||||
|
||||
@@ -581,10 +581,18 @@ _ccsg.EditBox.KeyboardReturnType = KeyboardReturnType;
|
||||
|
||||
tmpEdTxt.addEventListener('input', function () {
|
||||
var editBox = thisPointer._editBox;
|
||||
|
||||
|
||||
if (this.value.length > this.maxLength) {
|
||||
this.value = this.value.slice(0, this.maxLength);
|
||||
}
|
||||
|
||||
if (editBox._delegate && editBox._delegate.editBoxTextChanged) {
|
||||
editBox._text = this.value;
|
||||
thisPointer._updateEditBoxContentStyle();
|
||||
editBox._delegate.editBoxTextChanged(editBox, editBox._text);
|
||||
if (editBox._text.toLowerCase() !== this.value.toLowerCase()) {
|
||||
editBox._text = this.value;
|
||||
thisPointer._updateEditBoxContentStyle();
|
||||
editBox._delegate.editBoxTextChanged(editBox, editBox._text);
|
||||
}
|
||||
}
|
||||
});
|
||||
tmpEdTxt.addEventListener('keypress', function (e) {
|
||||
@@ -597,6 +605,7 @@ _ccsg.EditBox.KeyboardReturnType = KeyboardReturnType;
|
||||
this.style.fontSize = editBox._placeholderFontSize + 'px';
|
||||
this.style.color = cc.colorToHex(editBox._placeholderColor);
|
||||
}
|
||||
|
||||
editBox._text = this.value;
|
||||
thisPointer._updateEditBoxContentStyle();
|
||||
thisPointer.hidden();
|
||||
@@ -670,11 +679,17 @@ _ccsg.EditBox.KeyboardReturnType = KeyboardReturnType;
|
||||
tmpEdTxt.style.className = "cocosEditBox";
|
||||
|
||||
tmpEdTxt.addEventListener('input', function () {
|
||||
if (this.value.length > this.maxLength) {
|
||||
this.value = this.value.slice(0, this.maxLength);
|
||||
}
|
||||
|
||||
var editBox = thisPointer._editBox;
|
||||
if (editBox._delegate && editBox._delegate.editBoxTextChanged) {
|
||||
editBox._text = this.value;
|
||||
thisPointer._updateEditBoxContentStyle();
|
||||
editBox._delegate.editBoxTextChanged(editBox, editBox._text);
|
||||
if(editBox._text.toLowerCase() !== this.value.toLowerCase()) {
|
||||
editBox._text = this.value;
|
||||
thisPointer._updateEditBoxContentStyle();
|
||||
editBox._delegate.editBoxTextChanged(editBox, editBox._text);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ var View = cc._Class.extend({
|
||||
__resizeWithBrowserSize: false,
|
||||
_isAdjustViewPort: true,
|
||||
_targetDensityDPI: null,
|
||||
_antiAliasEnabled: false,
|
||||
_antiAliasEnabled: true,
|
||||
|
||||
/**
|
||||
* Constructor of View
|
||||
@@ -184,7 +184,6 @@ var View = cc._Class.extend({
|
||||
_t._rpFixedWidth = new cc.ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.FIXED_WIDTH);
|
||||
|
||||
_t._targetDensityDPI = cc.macro.DENSITYDPI_HIGH;
|
||||
_t.enableAntiAlias(true);
|
||||
},
|
||||
|
||||
// Resize helper functions
|
||||
@@ -469,7 +468,7 @@ var View = cc._Class.extend({
|
||||
* !#en Returns whether the current enable on anti-alias
|
||||
* !#zh 返回当前是否抗锯齿
|
||||
* @method isAntiAliasEnabled
|
||||
* @param {Boolean} enabled - Pass false to make pixel art sharp.
|
||||
* @return {Boolean}
|
||||
*/
|
||||
isAntiAliasEnabled: function () {
|
||||
return this._antiAliasEnabled;
|
||||
|
||||
@@ -125,6 +125,21 @@ var textureCache = /** @lends cc.textureCache# */{
|
||||
return this._textureColorsCache[key];
|
||||
},
|
||||
|
||||
/**
|
||||
* #en get all textures
|
||||
* #zh 获取所有贴图
|
||||
* @method getAllTextures
|
||||
* @return {Texture2D[]}
|
||||
*/
|
||||
getAllTextures: function () {
|
||||
var texs = [];
|
||||
for (var key in this._textures) {
|
||||
var item = this._textures[key];
|
||||
texs.push(item);
|
||||
}
|
||||
return texs;
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>Purges the dictionary of loaded textures. <br />
|
||||
* Call this method if you receive the "Memory Warning" <br />
|
||||
|
||||
Reference in New Issue
Block a user