Skip to content

Commit af297a9

Browse files
committed
update
1 parent 5619f52 commit af297a9

File tree

3 files changed

+68
-39
lines changed

3 files changed

+68
-39
lines changed

libs/events.js

+44-22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export default events;
22
import functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a from 'exports-loader?functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a!../../project/functions'
33
import events_c12a15a8_c380_4b28_8144_256cba95f760 from 'exports-loader?events_c12a15a8_c380_4b28_8144_256cba95f760!../../editor/project/events'
44
import route from '../../pixi/scenes/route';
5+
import ui from '../../pixi/ui';
56
"use strict";
67

78
function events() {
@@ -449,28 +450,39 @@ events.prototype._openDoor_check = function (id, x, y, needKey) {
449450

450451
events.prototype._openDoor_animate = function (id, x, y, callback) {
451452
var door = core.material.icons.animates[id];
452-
var speed = id.endsWith("Door") ? 30 : 70;
453+
var speed = id.endsWith("Door") ? 50 : 70;
453454

454455
var locked = core.status.lockControl;
455456
core.lockControl();
456457
core.status.replay.animate = true;
457458
core.removeBlock(x, y);
458-
core.drawImage('event', core.material.images.animates, 0, 32 * door, 32, 32, 32 * x, 32 * y, 32, 32);
459-
var state = 0;
460-
var animate = window.setInterval(function () {
461-
core.clearMap('event', 32 * x, 32 * y, 32, 32);
462-
state++;
463-
if (state == 4) {
464-
clearInterval(animate);
465-
delete core.animateFrame.asyncId[animate];
459+
const event = pixi.game.getScene('event');
460+
ui.drawAnimate(id, event, x * 32 + 16, y * 32 + 16, {
461+
async: true,
462+
time: core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1),
463+
onComplete() {
466464
if (!locked) core.unLockControl();
467465
core.status.replay.animate = false;
468466
core.events.afterOpenDoor(id, x, y, callback);
469467
return;
470468
}
471-
core.drawImage('event', core.material.images.animates, 32 * state, 32 * door, 32, 32, 32 * x, 32 * y, 32, 32);
472-
}, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1));
473-
core.animateFrame.asyncId[animate] = true;
469+
})
470+
// core.drawImage('event', core.material.images.animates, 0, 32 * door, 32, 32, 32 * x, 32 * y, 32, 32);
471+
// var state = 0;
472+
// var animate = window.setInterval(function () {
473+
// core.clearMap('event', 32 * x, 32 * y, 32, 32);
474+
// state++;
475+
// if (state == 4) {
476+
// clearInterval(animate);
477+
// delete core.animateFrame.asyncId[animate];
478+
// if (!locked) core.unLockControl();
479+
// core.status.replay.animate = false;
480+
// core.events.afterOpenDoor(id, x, y, callback);
481+
// return;
482+
// }
483+
// core.drawImage('event', core.material.images.animates, 32 * state, 32 * door, 32, 32, 32 * x, 32 * y, 32, 32);
484+
// }, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1));
485+
// core.animateFrame.asyncId[animate] = true;
474486
}
475487

476488
////// 开一个门后触发的事件 //////
@@ -2473,19 +2485,29 @@ events.prototype.closeDoor = function (x, y, id, callback) {
24732485
core.playSound('door.mp3');
24742486
var door = core.material.icons.animates[id];
24752487
var speed = id.endsWith("Door") ? 30 : 70, state = 0;
2476-
var animate = window.setInterval(function () {
2477-
state++;
2478-
if (state == 4) {
2479-
clearInterval(animate);
2480-
delete core.animateFrame.asyncId[animate];
2488+
const event = pixi.game.getScene('event');
2489+
ui.drawAnimate(id, event, x * 32 + 16, y * 32 + 16, {
2490+
async: true,
2491+
reverse: true,
2492+
time: core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1),
2493+
onComplete() {
24812494
core.setBlock(core.getNumberById(id), x, y);
24822495
if (callback) callback();
2483-
return;
24842496
}
2485-
core.clearMap('event', 32 * x, 32 * y, 32, 32);
2486-
core.drawImage('event', core.material.images.animates, 32 * (4-state), 32 * door, 32, 32, 32 * x, 32 * y, 32, 32);
2487-
}, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1));
2488-
core.animateFrame.asyncId[animate] = true;
2497+
})
2498+
// var animate = window.setInterval(function () {
2499+
// state++;
2500+
// if (state == 4) {
2501+
// clearInterval(animate);
2502+
// delete core.animateFrame.asyncId[animate];
2503+
// core.setBlock(core.getNumberById(id), x, y);
2504+
// if (callback) callback();
2505+
// return;
2506+
// }
2507+
// core.clearMap('event', 32 * x, 32 * y, 32, 32);
2508+
// core.drawImage('event', core.material.images.animates, 32 * (4-state), 32 * door, 32, 32, 32 * x, 32 * y, 32, 32);
2509+
// },);
2510+
// core.animateFrame.asyncId[animate] = true;
24892511
}
24902512

24912513
////// 显示图片 //////

libs/maps.js

+23-14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import utils from '../../pixi/utils';
55
import nodes from '../../pixi/nodes';
66
import hero from '../../pixi/scenes/hero';
77
import Block from '../../pixi/libs/Block';
8+
import ui from '../../pixi/ui.js';
89
"use strict";
910

1011
function maps() {
@@ -1730,12 +1731,13 @@ maps.prototype.moveBlock = function (x, y, steps, time, keep, callback) {
17301731
const moveSteps = (steps||[]).filter(function (t) {
17311732
return ['up','down','left','right','forward','backward'].indexOf(t)>=0;
17321733
});
1733-
const id = utils.getId();
1734-
core.animateFrame.asyncId[id] = true;
1735-
pixi.maps.moveBlock(block, moveSteps, time, keep, () => {
1736-
delete core.animateFrame.asyncId[id];
1737-
if (callback instanceof Function)callback();
1738-
});
1734+
ui.setAsyncAnimate((cb) => {
1735+
pixi.maps.moveBlock(block, moveSteps, time, keep, () => {
1736+
cb();
1737+
if (callback instanceof Function)callback();
1738+
});
1739+
})
1740+
17391741
// // var canvases = this._initDetachedBlock(blockInfo, x, y, block.event.animate !== false);
17401742
// // this._moveDetachedBlock(blockInfo, 32 * x, 32 * y, 1, canvases);
17411743
// var moveInfo = {
@@ -2011,10 +2013,14 @@ maps.prototype.drawBoxAnimate = function () {
20112013

20122014
////// 绘制动画 //////
20132015
maps.prototype.drawAnimate = function (name, x, y, callback) {
2014-
const animate = core.material.animates[name];
20152016
const centerX = 32 * x + 16;
20162017
const centerY = 32 * y + 16;
2017-
animate.play('event', centerX, centerY, null, callback);
2018+
const scene = pixi.game.getScene('event');
2019+
ui.drawAnimate(name, scene, centerX, centerY, {
2020+
onComplete() {
2021+
if (callback instanceof Function) callback();
2022+
}
2023+
})
20182024
// name = core.getMappedName(name);
20192025

20202026
// // 正在播放录像:不显示动画
@@ -2043,16 +2049,19 @@ maps.prototype.drawAnimate = function (name, x, y, callback) {
20432049

20442050
////// 绘制一个跟随勇士的动画 //////
20452051
maps.prototype.drawHeroAnimate = function (name, callback) {
2046-
const animate = core.material.animates[name];
20472052
if (!hero.sprite) return;
20482053
const centerX = hero.sprite.x || 0;
20492054
const centerY = hero.sprite.y || 0;
2050-
animate.play('event', centerX, centerY, (node) => {
2051-
if (hero.sprite) {
2052-
node.defaultX = hero.sprite.x;
2053-
node.defaultY = hero.sprite.y;
2055+
const scene = pixi.game.getScene('event');
2056+
ui.drawAnimate(name, scene, centerX, centerY, {
2057+
update() {
2058+
this.defaultX = hero.sprite.x;
2059+
this.defaultY = hero.sprite.y;
2060+
},
2061+
onComplete() {
2062+
if (callback instanceof Function) callback();
20542063
}
2055-
}, callback);
2064+
})
20562065
}
20572066

20582067
////// 绘制动画的某一帧 //////

main.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ main.dom.body.onkeyup = function(e) {
423423
////// 鼠标按下时 //////
424424
main.dom.data.onmousedown = function (e) {
425425
try {
426-
e.stopPropagation();
426+
// e.stopPropagation();
427427
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY);
428428
if (loc == null) return;
429429
main.core.ondown(loc);
@@ -433,7 +433,6 @@ main.dom.data.onmousedown = function (e) {
433433
////// 鼠标移动时 //////
434434
main.dom.data.onmousemove = function (e) {
435435
try {
436-
e.stopPropagation();
437436
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY);
438437
if (loc == null) return;
439438
main.core.onmove(loc);
@@ -443,7 +442,6 @@ main.dom.data.onmousemove = function (e) {
443442
////// 鼠标放开时 //////
444443
main.dom.data.onmouseup = function (e) {
445444
try {
446-
e.stopPropagation();
447445
var loc = main.core.actions._getClickLoc(e.clientX, e.clientY);
448446
if (loc == null) return;
449447
main.core.onup(loc);

0 commit comments

Comments
 (0)