Muliple Animations
This commit is contained in:
parent
1aef219f53
commit
b36e1bae30
@ -114,7 +114,10 @@ editor.prototype.idsInit = function (maps, icons) {
|
|||||||
var img = core.material.images.tilesets[imgName];
|
var img = core.material.images.tilesets[imgName];
|
||||||
var width = Math.floor(img.width/32), height = Math.floor(img.height/32);
|
var width = Math.floor(img.width/32), height = Math.floor(img.height/32);
|
||||||
if(img.width%32 || img.height%32){
|
if(img.width%32 || img.height%32){
|
||||||
alert(imgName+'的长或宽不是32的整数倍, 请修改后刷新页面')
|
alert(imgName+'的长或宽不是32的整数倍, 请修改后刷新页面');
|
||||||
|
}
|
||||||
|
if(img.width*img.height > 32*32*1000){
|
||||||
|
alert(imgName+'上的图块数量超过了1000,请修改后刷新页面');
|
||||||
}
|
}
|
||||||
for (var id=startOffset; id<startOffset+width*height;id++) {
|
for (var id=startOffset; id<startOffset+width*height;id++) {
|
||||||
var x = (id-startOffset)%width, y = parseInt((id-startOffset)/width);
|
var x = (id-startOffset)%width, y = parseInt((id-startOffset)/width);
|
||||||
|
|||||||
@ -56,6 +56,7 @@ control.prototype.setRequestAnimationFrame = function () {
|
|||||||
|
|
||||||
core.animateFrame.globalTime = core.animateFrame.globalTime||timestamp;
|
core.animateFrame.globalTime = core.animateFrame.globalTime||timestamp;
|
||||||
core.animateFrame.boxTime = core.animateFrame.boxTime||timestamp;
|
core.animateFrame.boxTime = core.animateFrame.boxTime||timestamp;
|
||||||
|
core.animateFrame.animateTime = core.animateFrame.animateTime||timestamp;
|
||||||
core.animateFrame.moveTime = core.animateFrame.moveTime||timestamp;
|
core.animateFrame.moveTime = core.animateFrame.moveTime||timestamp;
|
||||||
core.animateFrame.weather.time = core.animateFrame.weather.time||timestamp;
|
core.animateFrame.weather.time = core.animateFrame.weather.time||timestamp;
|
||||||
|
|
||||||
@ -88,6 +89,18 @@ control.prototype.setRequestAnimationFrame = function () {
|
|||||||
core.animateFrame.boxTime = timestamp;
|
core.animateFrame.boxTime = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Animate
|
||||||
|
if (timestamp-core.animateFrame.animateTime>50 && core.isset(core.status.animateObjs) && core.status.animateObjs.length>0) {
|
||||||
|
core.clearMap('animate');
|
||||||
|
core.status.animateObjs = core.status.animateObjs.filter(function (obj) {
|
||||||
|
return obj.index < obj.animate.frames.length;
|
||||||
|
})
|
||||||
|
core.status.animateObjs.forEach(function (obj) {
|
||||||
|
core.maps.drawAnimateFrame(obj.animate, obj.centerX, obj.centerY, obj.index++);
|
||||||
|
})
|
||||||
|
core.animateFrame.animateTime = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
// Hero move
|
// Hero move
|
||||||
if (timestamp-core.animateFrame.moveTime>16 && core.isset(core.status.heroMoving) && core.status.heroMoving>0) {
|
if (timestamp-core.animateFrame.moveTime>16 && core.isset(core.status.heroMoving) && core.status.heroMoving>0) {
|
||||||
var x=core.getHeroLoc('x'), y=core.getHeroLoc('y'), direction = core.getHeroLoc('direction');
|
var x=core.getHeroLoc('x'), y=core.getHeroLoc('y'), direction = core.getHeroLoc('direction');
|
||||||
|
|||||||
@ -31,6 +31,7 @@ function core() {
|
|||||||
'globalAnimate': false,
|
'globalAnimate': false,
|
||||||
'globalTime': null,
|
'globalTime': null,
|
||||||
'boxTime': null,
|
'boxTime': null,
|
||||||
|
'animateTime': null,
|
||||||
'moveTime': null,
|
'moveTime': null,
|
||||||
'speed': null,
|
'speed': null,
|
||||||
'weather': {
|
'weather': {
|
||||||
@ -157,6 +158,7 @@ function core() {
|
|||||||
// 动画
|
// 动画
|
||||||
'globalAnimateObjs': [],
|
'globalAnimateObjs': [],
|
||||||
'boxAnimateObjs': [],
|
'boxAnimateObjs': [],
|
||||||
|
'animateObjs': [],
|
||||||
};
|
};
|
||||||
this.status = {};
|
this.status = {};
|
||||||
}
|
}
|
||||||
|
|||||||
69
libs/maps.js
69
libs/maps.js
@ -1180,38 +1180,10 @@ maps.prototype.drawBoxAnimate = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////// 绘制动画 //////
|
////// 绘制动画的某一帧 //////
|
||||||
maps.prototype.drawAnimate = function (name, x, y, callback) {
|
maps.prototype.drawAnimateFrame = function (animate, centerX, centerY, index) {
|
||||||
|
|
||||||
// 正在播放录像:不显示动画
|
|
||||||
if (core.isset(core.status.replay) && core.status.replay.replaying) {
|
|
||||||
if (core.isset(callback)) callback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检测动画是否存在
|
|
||||||
if (!core.isset(core.material.animates[name]) || !core.isset(x) || !core.isset(y)) {
|
|
||||||
if (core.isset(callback)) callback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 清空animate层
|
|
||||||
clearInterval(core.interval.animateInterval);
|
|
||||||
core.clearMap('animate');
|
|
||||||
|
|
||||||
// 开始绘制
|
|
||||||
var animate = core.material.animates[name];
|
|
||||||
var ratio = animate.ratio;
|
|
||||||
var centerX = 32*x+16, centerY = 32*y+16;
|
|
||||||
var index=0;
|
|
||||||
|
|
||||||
// 播放音效
|
|
||||||
core.playSound(animate.se);
|
|
||||||
|
|
||||||
var draw = function (index) {
|
|
||||||
core.clearMap('animate');
|
|
||||||
|
|
||||||
var frame = animate.frames[index];
|
var frame = animate.frames[index];
|
||||||
|
var ratio = animate.ratio;
|
||||||
frame.forEach(function (t) {
|
frame.forEach(function (t) {
|
||||||
var image = animate.images[t.index];
|
var image = animate.images[t.index];
|
||||||
if (!core.isset(image)) return;
|
if (!core.isset(image)) return;
|
||||||
@ -1237,7 +1209,37 @@ maps.prototype.drawAnimate = function (name, x, y, callback) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
draw(index++);
|
////// 绘制动画 //////
|
||||||
|
maps.prototype.drawAnimate = function (name, x, y, callback) {
|
||||||
|
|
||||||
|
// 正在播放录像:不显示动画
|
||||||
|
if (core.isset(core.status.replay) && core.status.replay.replaying) {
|
||||||
|
if (core.isset(callback)) callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测动画是否存在
|
||||||
|
if (!core.isset(core.material.animates[name]) || !core.isset(x) || !core.isset(y)) {
|
||||||
|
if (core.isset(callback)) callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearInterval(core.interval.animateInterval);
|
||||||
|
|
||||||
|
// 开始绘制
|
||||||
|
var animate = core.material.animates[name], centerX = 32*x+16, centerY = 32*y+16;
|
||||||
|
// 播放音效
|
||||||
|
core.playSound(animate.se);
|
||||||
|
|
||||||
|
// 异步绘制:使用requestAnimationFrame进行绘制
|
||||||
|
if (!core.isset(callback)) {
|
||||||
|
core.status.animateObjs.push({"animate": animate, "centerX": centerX, "centerY": centerY, "index": 0});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var index=0;
|
||||||
|
core.clearMap('animate');
|
||||||
|
core.maps.drawAnimateFrame(animate, centerX, centerY, index++);
|
||||||
|
|
||||||
core.interval.animateInterval = setInterval(function (t) {
|
core.interval.animateInterval = setInterval(function (t) {
|
||||||
if (index == animate.frames.length) {
|
if (index == animate.frames.length) {
|
||||||
@ -1247,7 +1249,8 @@ maps.prototype.drawAnimate = function (name, x, y, callback) {
|
|||||||
if (core.isset(callback)) callback();
|
if (core.isset(callback)) callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
draw(index++);
|
core.clearMap('animate');
|
||||||
|
core.maps.drawAnimateFrame(animate, centerX, centerY, index++);
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
更新说明.txt
15
更新说明.txt
@ -1,4 +1,17 @@
|
|||||||
HTML5魔塔样板V2.4.1
|
HTML5魔塔样板V2.4.2
|
||||||
|
|
||||||
|
允许导入tilesets直接使用,无需PS和注册
|
||||||
|
tilesets的素材允许以矩形方式整体绘制
|
||||||
|
增加了透明块的支持
|
||||||
|
装备允许按照百分比增加属性
|
||||||
|
多动画的同时播放
|
||||||
|
修复了打开存读档页面时闪屏的问题
|
||||||
|
修复了cannotMove仍然能轻按和瞬移的问题
|
||||||
|
所有已知Bug修复,部分代码重构和细节优化
|
||||||
|
|
||||||
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
HTML5魔塔样板V2.4.1
|
||||||
|
|
||||||
增加背景层和前景层的图块绘制,多层图块可叠加
|
增加背景层和前景层的图块绘制,多层图块可叠加
|
||||||
背景层/前景层图块的显示、隐藏、修改等事件
|
背景层/前景层图块的显示、隐藏、修改等事件
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user