mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 08:42:43 +08:00
Fix more issues for 2.0 (#2662)
* Use black as camera default clear color * Fix director delta time issue in editor * Fix particle system init and editor update issue * Improve Node API ref
This commit is contained in:
@@ -916,6 +916,8 @@ cc.Director.prototype = {
|
||||
* Run main loop of director
|
||||
*/
|
||||
mainLoop: CC_EDITOR ? function (deltaTime, updateAnimate) {
|
||||
this._deltaTime = deltaTime;
|
||||
|
||||
// Update
|
||||
if (!this._paused) {
|
||||
this.emit(cc.Director.EVENT_BEFORE_UPDATE);
|
||||
|
||||
+14
-12
@@ -2508,8 +2508,12 @@ var Node = cc.Class({
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en Converts a Point to node (local) space coordinates. The result is in Vec2.
|
||||
* !#zh 将一个点转换到节点 (局部) 坐标系。结果以 Vec2 为单位。
|
||||
* !#en Converts a Point to node (local) space coordinates then add the anchor point position.
|
||||
* So the return position will be related to the left bottom corner of the node's bounding box.
|
||||
* This equals to the API behavior of cocos2d-x, you probably want to use convertToNodeSpaceAR instead
|
||||
* !#zh 将一个点转换到节点 (局部) 坐标系,并加上锚点的坐标。<br/>
|
||||
* 也就是说返回的坐标是相对于节点包围盒左下角的坐标。<br/>
|
||||
* 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToNodeSpaceAR。
|
||||
* @method convertToNodeSpace
|
||||
* @param {Vec2} worldPoint
|
||||
* @return {Vec2}
|
||||
@@ -2527,8 +2531,10 @@ var Node = cc.Class({
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en Converts a Point to world space coordinates. The result is in Points.
|
||||
* !#zh 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。
|
||||
* !#en Converts a Point related to the left bottom corner of the node's bounding box to world space coordinates.
|
||||
* This equals to the API behavior of cocos2d-x, you probably want to use convertToWorldSpaceAR instead
|
||||
* !#zh 将一个相对于节点左下角的坐标位置转换到世界空间坐标系。
|
||||
* 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToWorldSpaceAR
|
||||
* @method convertToWorldSpace
|
||||
* @param {Vec2} nodePoint
|
||||
* @return {Vec2}
|
||||
@@ -2546,11 +2552,9 @@ var Node = cc.Class({
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Converts a Point to node (local) space coordinates. The result is in Points.<br/>
|
||||
* treating the returned/received node point as anchor relative.
|
||||
* Converts a Point to node (local) space coordinates in which the anchor point is the origin position.
|
||||
* !#zh
|
||||
* 将一个点转换到节点 (局部) 空间坐标系。结果以 Vec2 为单位。<br/>
|
||||
* 返回值将基于节点坐标。
|
||||
* 将一个点转换到节点 (局部) 空间坐标系,这个坐标系以锚点为原点。
|
||||
* @method convertToNodeSpaceAR
|
||||
* @param {Vec2} worldPoint
|
||||
* @return {Vec2}
|
||||
@@ -2566,11 +2570,9 @@ var Node = cc.Class({
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Converts a local Point to world space coordinates.The result is in Points.<br/>
|
||||
* treating the returned/received node point as anchor relative.
|
||||
* Converts a Point in node coordinates to world space coordinates.
|
||||
* !#zh
|
||||
* 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。<br/>
|
||||
* 返回值将基于世界坐标。
|
||||
* 将节点坐标系下的一个点转换到世界空间坐标系。
|
||||
* @method convertToWorldSpaceAR
|
||||
* @param {Vec2} nodePoint
|
||||
* @return {Vec2}
|
||||
|
||||
@@ -95,7 +95,7 @@ let Camera = cc.Class({
|
||||
properties: {
|
||||
_cullingMask: 0xffffffff,
|
||||
_clearFlags: 0,
|
||||
_backgroundColor: cc.color(51, 77, 120, 255),
|
||||
_backgroundColor: cc.color(0, 0, 0, 255),
|
||||
_depth: 0,
|
||||
_zoomRatio: 1,
|
||||
_targetTexture: null,
|
||||
|
||||
@@ -901,6 +901,7 @@ var ParticleSystem = cc.Class({
|
||||
|
||||
// vfx handle real particle step process based on GPU shaders
|
||||
this._vfx = new Particles(cc.renderer.device, cc.renderer._forward, this);
|
||||
this._vfx.stopSystem();
|
||||
this._vertexFormat = this._vfx.vertexFormat;
|
||||
|
||||
// Config update flags, vfx constructor has updated with the current config, so not dirty
|
||||
@@ -976,10 +977,10 @@ var ParticleSystem = cc.Class({
|
||||
|
||||
onEnable: function () {
|
||||
this._super();
|
||||
this._updateMaterial();
|
||||
|
||||
// should add render flag after particle loaded
|
||||
this.node._renderFlag &= !(RenderFlow.FLAG_RENDER | RenderFlow.FLAG_UPDATE_RENDER_DATA);
|
||||
|
||||
this._updateMaterial();
|
||||
},
|
||||
|
||||
onDestroy: function () {
|
||||
@@ -995,11 +996,12 @@ var ParticleSystem = cc.Class({
|
||||
this._focused = true;
|
||||
if (this.preview) {
|
||||
this.resetSystem();
|
||||
this.node._renderFlag |= RenderFlow.FLAG_RENDER | RenderFlow.FLAG_UPDATE_RENDER_DATA;
|
||||
|
||||
var self = this;
|
||||
this._previewTimer = setInterval(function () {
|
||||
// attemptToReplay
|
||||
if (self.particleCount === 0 && !self._willStart) {
|
||||
if (self._vfx && !self._willStart && self.particleCount === 0) {
|
||||
self._willStart = true;
|
||||
setTimeout(function () {
|
||||
self._willStart = false;
|
||||
@@ -1017,6 +1019,7 @@ var ParticleSystem = cc.Class({
|
||||
if (this.preview) {
|
||||
this.resetSystem();
|
||||
this.stopSystem();
|
||||
this.node._renderFlag &= !(RenderFlow.FLAG_RENDER | RenderFlow.FLAG_UPDATE_RENDER_DATA);
|
||||
cc.engine.repaintInEditMode();
|
||||
}
|
||||
if (this._previewTimer) {
|
||||
@@ -1291,9 +1294,7 @@ var ParticleSystem = cc.Class({
|
||||
this._renderData.uvDirty = true;
|
||||
}
|
||||
// Reactivate material
|
||||
if (this.enabledInHierarchy) {
|
||||
this._updateMaterial();
|
||||
}
|
||||
this._updateMaterial();
|
||||
},
|
||||
|
||||
_applySpriteFrame: function (oldFrame) {
|
||||
@@ -1328,6 +1329,9 @@ var ParticleSystem = cc.Class({
|
||||
_updateMaterial: function () {
|
||||
// cannot be activated if texture not loaded yet
|
||||
if (!this._texture || !this._texture.loaded) {
|
||||
if (this._spriteFrame) {
|
||||
this._applySpriteFrame();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user