Commit 1d743af7 authored by rockyl's avatar rockyl

修复

parent e1c65b21
......@@ -19,7 +19,7 @@
"complete"
],
"id": "add-custom-module",
"script": "var p = engine.findVariable('props', args, props);\nengine.addCustomModule(props.id, props.target || target, p);\nnext('complete');\n",
"script": "var p = engine.findVariable('props', args, props);\nvar id = engine.findVariable('id', args, props);\nvar target2 = engine.findVariable('target', args, props);\nengine.addCustomModule(id, target2 || target, p);\nnext('complete');\n",
"group": "view",
"type": "builtin"
}
......@@ -44,7 +44,7 @@
"complete"
],
"id": "pop-dialog",
"script": "var effect = engine.findVariable('effect', args, props);\nvar effectParams = engine.findVariable('effectParams', args, props);\nvar options = {\n effect: effect,\n effectParams: effectParams,\n};\nif (props.closeAll) {\n engine.gameStage.popupContainer.popAll(options);\n}\nelse {\n engine.gameStage.popupContainer.pop(options);\n}\nnext('complete');\n",
"script": "var effect = engine.findVariable('effect', args, props);\nvar effectParams = engine.findVariable('effectParams', args, props);\nvar options = {\n effect: effect,\n effectParams: effectParams,\n};\nif (props.closeAll) {\n engine.gameStage.popupContainer.popAll(null, options);\n}\nelse {\n engine.gameStage.popupContainer.pop(options);\n}\nnext('complete');\n",
"group": "view",
"type": "builtin"
}
......@@ -6,11 +6,21 @@
"alias": "目标视图名",
"type": "string"
},
"showLoading": {
"alias": "展示加载视图",
"type": "boolean",
"default": true
},
"center": {
"alias": "是否居中展示",
"type": "boolean",
"default": true
},
"modalAlpha": {
"alias": "模态层透明度",
"type": "number",
"default": 0.7
},
"effect": {
"alias": "动效",
"type": "enum",
......@@ -48,7 +58,7 @@
"complete"
],
"id": "push-dialog",
"script": "var effect = engine.findVariable('effect', args, props);\nvar effectParams = engine.findVariable('effectParams', args, props);\nif (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage_1 = engine.gameStage;\n gameStage_1.instantiateView(props.viewName).then(function (view) {\n if (view) {\n var options = {\n effect: effect,\n effectParams: effectParams,\n center: props.center,\n };\n gameStage_1.popupContainer.push(view, options);\n }\n });\n next('complete');\n}\n",
"script": "var effect = engine.findVariable('effect', args, props);\nvar effectParams = engine.findVariable('effectParams', args, props);\nvar showLoading = engine.findVariable('showLoading', args, props);\nif (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage_1 = engine.gameStage;\n gameStage_1.instantiateView(props.viewName, true, showLoading).then(function (view) {\n if (view) {\n var options = {\n effect: effect,\n effectParams: effectParams,\n center: props.center,\n modalAlpha: props.modalAlpha,\n };\n gameStage_1.popupContainer.push(view, options);\n }\n });\n next('complete');\n}\n",
"group": "view",
"type": "builtin"
}
......@@ -6,6 +6,11 @@
"alias": "目标视图名",
"type": "string"
},
"showLoading": {
"alias": "展示加载视图",
"type": "boolean",
"default": true
},
"replace": {
"alias": "是否替换场景",
"type": "boolean",
......@@ -36,7 +41,7 @@
"complete"
],
"id": "push-scene",
"script": "var replace = engine.findVariable('replace', args, props);\nvar effect = engine.findVariable('effect', args, props);\nvar effectParams = engine.findVariable('effectParams', args, props);\nif (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage_1 = engine.gameStage;\n gameStage_1.instantiateView(props.viewName).then(function (view) {\n if (view) {\n var options = {\n effect: effect,\n effectParams: effectParams,\n };\n if (replace) {\n gameStage_1.sceneContainer.replace(view, options);\n }\n else {\n gameStage_1.sceneContainer.push(view, options);\n }\n }\n });\n next('complete');\n}\n",
"script": "var replace = engine.findVariable('replace', args, props);\nvar effect = engine.findVariable('effect', args, props);\nvar effectParams = engine.findVariable('effectParams', args, props);\nvar showLoading = engine.findVariable('showLoading', args, props);\nif (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage_1 = engine.gameStage;\n gameStage_1.instantiateView(props.viewName, true, showLoading).then(function (view) {\n if (view) {\n var options = {\n effect: effect,\n effectParams: effectParams,\n };\n if (replace) {\n gameStage_1.sceneContainer.replace(view, options);\n }\n else {\n gameStage_1.sceneContainer.push(view, options);\n }\n }\n });\n next('complete');\n}\n",
"group": "view",
"type": "builtin"
}
......@@ -13,6 +13,19 @@
"default": 10,
"alias": "边距"
},
"paddingH": {
"type": "number",
"alias": "横向边距"
},
"paddingV": {
"type": "number",
"alias": "纵向边距"
},
"borderRadius": {
"type": "number",
"default": 10,
"alias": "圆角半径"
},
"duration": {
"type": "number",
"default": 1000,
......
This diff is collapsed.
var p = engine.findVariable('props', args, props);
var id = engine.findVariable('id', args, props);
var target2 = engine.findVariable('target', args, props);
engine.addCustomModule(id, target2 || target, p);
next('complete');
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Wave = (function (_super) {
__extends(Wave, _super);
function Wave() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.duration = 1000;
_this.waveMethod = 'rotate';
_this.loop = -1;
_this.autoPlay = true;
_this.revert = false;
_this._oldProps = {};
return _this;
}
Wave.prototype.mounted = function () {
this._startTime = 0;
engine.copyProp(this._oldProps, this.host, oldPropFields);
if (this.autoPlay) {
this.play();
}
};
Wave.prototype.sleep = function () {
if (this.revert) {
this.revertProps();
}
};
Wave.prototype.update = function (t) {
if (this._playing) {
if (!this._startTime) {
this._startTime = t;
}
var _a = this, duration_1 = _a.duration, waveParams = _a.waveParams, _waveAlgorithm = _a._waveAlgorithm, host = _a.host, _oldProps = _a._oldProps;
var pass = (t - this._startTime) % duration_1;
var r = pass / duration_1 * PI2;
var loopCounting = Math.floor((t - this._startTime) / duration_1);
if (loopCounting != this._loopCounting) {
this._loopCounting = loopCounting;
if (this.onLoopEnd()) {
r = PI2;
}
}
var t2 = void 0;
if (this.ratio) {
var ratio = this.ratio.split(',').map(function (item) { return parseFloat(item); });
if (ratio.length === 2) {
var begin = ratio[0], end = ratio[1];
if (end >= begin) {
var tr = r / PI2;
if (tr >= begin && tr < end) {
t2 = r / (end - begin);
}
else {
t2 = 0;
}
}
else {
t2 = 0;
}
}
else {
t2 = 0;
}
}
else {
t2 = r;
}
var params_1 = waveParams ? (waveParams.split(',').map(function (item) { return parseFloat(item); })) : [];
var props_1 = _waveAlgorithm.apply(void 0, params_1.concat([t2]));
if (props_1.hasOwnProperty('x')) {
host.x = (props_1.x || 0) + _oldProps.x;
}
if (props_1.hasOwnProperty('y')) {
host.y = (props_1.y || 0) + _oldProps.y;
}
if (props_1.hasOwnProperty('sx')) {
host.scaleX = props_1.sx;
}
if (props_1.hasOwnProperty('sy')) {
host.scaleY = props_1.sy;
}
if (props_1.hasOwnProperty('r')) {
host.rotation = props_1.r;
}
if (props_1.hasOwnProperty('alpha')) {
host.alpha = props_1.alpha;
}
}
};
Wave.prototype.onLoopEnd = function () {
if (this.loop < 0) {
}
else if (this._loopCounting < this.loop) {
}
else {
this._playing = false;
return true;
}
};
Wave.prototype.play = function () {
this._loopCounting = 0;
this._playing = true;
this._startTime = 0;
};
Wave.prototype.stop = function (revert) {
if (revert === void 0) { revert = false; }
this._playing = false;
if (revert) {
this.revertProps();
}
};
Wave.prototype.revertProps = function () {
for (var key_1 in this._oldProps) {
var prop = this._oldProps[key_1];
if (typeof prop === 'object') {
engine.injectProp(this.host[key_1], prop);
}
else {
this.host[key_1] = prop;
}
}
};
Wave.prototype.onModify = function (value, key, oldValue) {
switch (key) {
case 'waveMethod':
this._waveAlgorithm = waveLibs[this.waveMethod];
break;
}
};
Wave.id = 'wave';
__decorate([
engine.dirtyFieldTrigger
], Wave.prototype, "waveMethod", void 0);
return Wave;
}(engine.ScriptBase));
exports.default = Wave;
var PI2 = Math.PI * 2;
var oldPropFields = {
x: 'x',
y: 'y',
scaleX: 'scaleX',
scaleY: 'scaleY',
alpha: 'alpha',
rotation: 'rotation',
};
var cos = Math.cos, sin = Math.sin, PI = Math.PI;
var waveLibs = {
round: function (radius, t) {
return { x: cos(t) * radius, y: sin(t) * radius };
},
cosWave: function (h, t) {
return { x: cos(t) * h, y: 0 };
},
sinWave: function (h, t) {
h = h || 1;
return { x: 0, y: sin(t) * h };
},
rotate: function (t) {
return { r: 360 * t / PI / 2 };
},
shake: function (angle, count, t) {
return { r: sin(t * count) * angle };
},
breath: function (scale, t) {
if (scale === void 0) { scale = 0.1; }
return { sx: sin(t) * scale + 1, sy: -sin(t + PI / 4) * scale + 1 };
},
zoom: function (scale, t) {
if (scale === void 0) { scale = 0.1; }
return { sx: sin(t) * scale + 1, sy: sin(t) * scale + 1 };
},
fade: function (base, scale, t) {
if (base === void 0) { base = 0; }
if (scale === void 0) { scale = 1; }
return { alpha: (sin(t) + 1) * 0.5 * scale + base };
},
};
......@@ -3,6 +3,8 @@
*/
let p = engine.findVariable('props', args, props);
let id = engine.findVariable('id', args, props);
let target2 = engine.findVariable('target', args, props);
engine.addCustomModule(props.id, props.target || target, p);
engine.addCustomModule(id, target2 || target, p);
next('complete');
......@@ -10,7 +10,7 @@ let options = {
effectParams,
};
if(props.closeAll){
engine.gameStage.popupContainer.popAll(options);
engine.gameStage.popupContainer.popAll(null, options);
}else{
engine.gameStage.popupContainer.pop(options);
}
......
......@@ -4,19 +4,21 @@
let effect = engine.findVariable('effect', args, props);
let effectParams = engine.findVariable('effectParams', args, props);
let showLoading = engine.findVariable('showLoading', args, props);
if (!props.viewName) {
console.log('没有设置视图名');
next('exception', '没有设置视图名');
} else {
let gameStage = engine.gameStage;
gameStage.instantiateView(props.viewName).then(
gameStage.instantiateView(props.viewName, true, showLoading).then(
view => {
if (view) {
let options = {
effect,
effectParams,
center: props.center,
modalAlpha: props.modalAlpha,
};
gameStage.popupContainer.push(view, options);
}
......
......@@ -6,11 +6,21 @@
"alias": "目标视图名",
"type": "string"
},
"showLoading": {
"alias": "展示加载视图",
"type": "boolean",
"default": true
},
"center": {
"alias": "是否居中展示",
"type": "boolean",
"default": true
},
"modalAlpha": {
"alias": "模态层透明度",
"type": "number",
"default": 0.7
},
"effect": {
"alias": "动效",
"type": "enum",
......
......@@ -5,13 +5,14 @@
let replace = engine.findVariable('replace', args, props);
let effect = engine.findVariable('effect', args, props);
let effectParams = engine.findVariable('effectParams', args, props);
let showLoading = engine.findVariable('showLoading', args, props);
if (!props.viewName) {
console.log('没有设置视图名');
next('exception', '没有设置视图名');
} else {
let gameStage = engine.gameStage;
gameStage.instantiateView(props.viewName).then(
gameStage.instantiateView(props.viewName, true, showLoading).then(
view => {
if (view) {
let options = {
......
......@@ -6,6 +6,11 @@
"alias": "目标视图名",
"type": "string"
},
"showLoading": {
"alias": "展示加载视图",
"type": "boolean",
"default": true
},
"replace": {
"alias": "是否替换场景",
"type": "boolean",
......
......@@ -13,6 +13,19 @@
"default": 10,
"alias": "边距"
},
"paddingH": {
"type": "number",
"alias": "横向边距"
},
"paddingV": {
"type": "number",
"alias": "纵向边距"
},
"borderRadius": {
"type": "number",
"default": 10,
"alias": "圆角半径"
},
"duration": {
"type": "number",
"default": 1000,
......
......@@ -31,7 +31,7 @@ export default class Wave extends engine.ScriptBase {
}
sleep(): void {
if(this.revert){
if (this.revert) {
this.revertProps();
}
}
......@@ -60,17 +60,17 @@ export default class Wave extends engine.ScriptBase {
let ratio = this.ratio.split(',').map(item => parseFloat(item));
if (ratio.length === 2) {
const [begin, end] = ratio;
if(end >= begin){
if (end >= begin) {
let tr = r / PI2;
if(tr >= begin && tr < end){
if (tr >= begin && tr < end) {
t2 = r / (end - begin);
}else{
} else {
t2 = 0;
}
}else{
} else {
t2 = 0;
}
}else{
} else {
t2 = 0;
}
} else {
......@@ -94,6 +94,9 @@ export default class Wave extends engine.ScriptBase {
if (props.hasOwnProperty('r')) {
host.rotation = props.r;
}
if (props.hasOwnProperty('alpha')) {
host.alpha = props.alpha;
}
}
}
......@@ -126,7 +129,7 @@ export default class Wave extends engine.ScriptBase {
}
}
revertProps(){
revertProps() {
for (let key in this._oldProps) {
let prop = this._oldProps[key];
if (typeof prop === 'object') {
......@@ -189,7 +192,7 @@ const waveLibs = {
return {sx: sin(t) * scale + 1, sy: sin(t) * scale + 1};
},
fade: function (base = 1, t: number): any {
return {alpha: (sin(t) + 1) * 0.5 + base};
fade: function (base = 0, scale = 1, t: number): any {
return {alpha: (sin(t) + 1) * 0.5 * scale + base};
},
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment