增加逐帧调整位置的功能
This commit is contained in:
parent
0ab075ebd1
commit
1269e85198
458
index.html
458
index.html
@ -3,22 +3,23 @@
|
||||
|
||||
<head>
|
||||
<script>
|
||||
if(typeof window.require==="function"){
|
||||
// 重命名 Electron 提供的 require
|
||||
window.nodeRequire = require;
|
||||
delete window.require;
|
||||
delete window.exports;
|
||||
delete window.module;
|
||||
}
|
||||
if (typeof window.require === 'function') {
|
||||
// 重命名 Electron 提供的 require
|
||||
window.nodeRequire = require;
|
||||
delete window.require;
|
||||
delete window.exports;
|
||||
delete window.module;
|
||||
}
|
||||
</script>
|
||||
<meta charset="utf-8">
|
||||
<title>特效查看及修改TOOL</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="full-screen" content="true" />
|
||||
<meta name="screen-orientation" content="portrait" />
|
||||
<meta name="x5-fullscreen" content="true" />
|
||||
<meta name="360-fullscreen" content="true" />
|
||||
<meta name="viewport"
|
||||
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
||||
<meta name="full-screen" content="true"/>
|
||||
<meta name="screen-orientation" content="portrait"/>
|
||||
<meta name="x5-fullscreen" content="true"/>
|
||||
<meta name="360-fullscreen" content="true"/>
|
||||
<style>
|
||||
html, body {
|
||||
-ms-touch-action: none;
|
||||
@ -28,216 +29,275 @@
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
}
|
||||
.red {
|
||||
background-color: red!important;
|
||||
}
|
||||
.red .panel-title{
|
||||
color: white!important;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="libs/easyui/themes/default/easyui.css" />
|
||||
<link rel="stylesheet" type="text/css" href="libs/easyui/themes/icon.css" />
|
||||
<link rel="stylesheet" type="text/css" href="libs/easyui/themes/material/easyui.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="libs/easyui/themes/icon.css"/>
|
||||
<script src="libs/jquery.min.js"></script>
|
||||
<script src="libs/easyui/jquery.easyui.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
var loadScript = function (list, callback) {
|
||||
var loaded = 0;
|
||||
var loadNext = function () {
|
||||
loadSingleScript(list[loaded], function () {
|
||||
loaded++;
|
||||
if (loaded >= list.length) {
|
||||
callback();
|
||||
}
|
||||
else {
|
||||
loadNext();
|
||||
}
|
||||
})
|
||||
};
|
||||
loadNext();
|
||||
};
|
||||
<script>
|
||||
var loadScript = function (list, callback) {
|
||||
var loaded = 0;
|
||||
var loadNext = function () {
|
||||
loadSingleScript(list[loaded], function () {
|
||||
loaded++;
|
||||
if (loaded >= list.length) {
|
||||
callback();
|
||||
} else {
|
||||
loadNext();
|
||||
}
|
||||
})
|
||||
};
|
||||
loadNext();
|
||||
};
|
||||
|
||||
var loadSingleScript = function (src, callback) {
|
||||
var s = document.createElement('script');
|
||||
s.async = false;
|
||||
s.src = src;
|
||||
s.addEventListener('load', function () {
|
||||
s.parentNode.removeChild(s);
|
||||
s.removeEventListener('load', arguments.callee, false);
|
||||
callback();
|
||||
}, false);
|
||||
document.body.appendChild(s);
|
||||
};
|
||||
var loadSingleScript = function (src, callback) {
|
||||
var s = document.createElement('script');
|
||||
s.async = false;
|
||||
s.src = src;
|
||||
s.addEventListener('load', function () {
|
||||
s.parentNode.removeChild(s);
|
||||
s.removeEventListener('load', arguments.callee, false);
|
||||
callback();
|
||||
}, false);
|
||||
document.body.appendChild(s);
|
||||
};
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', './manifest.json?v=' + Math.random(), true);
|
||||
xhr.addEventListener("load", function () {
|
||||
var manifest = JSON.parse(xhr.response);
|
||||
var list = manifest.initial.concat(manifest.game);
|
||||
loadScript(list, function () {
|
||||
/**
|
||||
* {
|
||||
* "renderMode":, //Engine rendering mode, "canvas" or "webgl"
|
||||
* "audioType": 0 //Use the audio type, 0: default, 2: web audio, 3: audio
|
||||
* "antialias": //Whether the anti-aliasing is enabled in WebGL mode, true: on, false: off, defaults to false
|
||||
* "calculateCanvasScaleFactor": //a function return canvas scale factor
|
||||
* }
|
||||
**/
|
||||
egret.runEgret({ renderMode: "webgl", audioType: 0, calculateCanvasScaleFactor:function(context) {
|
||||
var backingStore = context.backingStorePixelRatio ||
|
||||
context.webkitBackingStorePixelRatio ||
|
||||
context.mozBackingStorePixelRatio ||
|
||||
context.msBackingStorePixelRatio ||
|
||||
context.oBackingStorePixelRatio ||
|
||||
context.backingStorePixelRatio || 1;
|
||||
return (window.devicePixelRatio || 1) / backingStore;
|
||||
}});
|
||||
});
|
||||
});
|
||||
xhr.send(null);
|
||||
</script>
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', './manifest.json?v=' + Math.random(), true);
|
||||
xhr.addEventListener('load', function () {
|
||||
var manifest = JSON.parse(xhr.response);
|
||||
var list = manifest.initial.concat(manifest.game);
|
||||
loadScript(list, function () {
|
||||
/**
|
||||
* {
|
||||
* "renderMode":, //Engine rendering mode, "canvas" or "webgl"
|
||||
* "audioType": 0 //Use the audio type, 0: default, 2: web audio, 3: audio
|
||||
* "antialias": //Whether the anti-aliasing is enabled in WebGL mode, true: on, false: off, defaults to false
|
||||
* "calculateCanvasScaleFactor": //a function return canvas scale factor
|
||||
* }
|
||||
**/
|
||||
egret.runEgret({
|
||||
renderMode: 'webgl', audioType: 0, calculateCanvasScaleFactor: function (context) {
|
||||
var backingStore = context.backingStorePixelRatio ||
|
||||
context.webkitBackingStorePixelRatio ||
|
||||
context.mozBackingStorePixelRatio ||
|
||||
context.msBackingStorePixelRatio ||
|
||||
context.oBackingStorePixelRatio ||
|
||||
context.backingStorePixelRatio || 1;
|
||||
return (window.devicePixelRatio || 1) / backingStore;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
xhr.send(null);
|
||||
</script>
|
||||
|
||||
<div style="margin: auto;width: 50%;height: 100%;" class="egret-player"
|
||||
data-entry-class="Main"
|
||||
data-orientation="auto"
|
||||
data-scale-mode="noScale"
|
||||
data-frame-rate="30"
|
||||
data-content-width="400"
|
||||
data-content-height="1136"
|
||||
data-multi-fingered="2"
|
||||
data-show-fps="false" data-show-log="false"
|
||||
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
|
||||
</div>
|
||||
<div style="margin: auto;width: 50%;height: 100%;float:right;background:#fcfcfc">
|
||||
<table id="dg" class="easyui-datagrid" title="编辑特效" style="width:700px;height:auto" data-options="
|
||||
<div style="margin: auto;width: 50%;height: 100%;" class="egret-player"
|
||||
data-entry-class="Main"
|
||||
data-orientation="auto"
|
||||
data-scale-mode="noScale"
|
||||
data-frame-rate="30"
|
||||
data-content-width="400"
|
||||
data-content-height="1136"
|
||||
data-multi-fingered="2"
|
||||
data-show-fps="false" data-show-log="false"
|
||||
data-show-fps-style="x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9">
|
||||
</div>
|
||||
<div style="margin: auto;width: 50%;height: 100%;float:right;background:#fcfcfc">
|
||||
<table id="dg" class="easyui-datagrid" title="编辑特效" style="width:700px;height:auto" data-options="
|
||||
iconCls: 'icon-edit',
|
||||
singleSelect: true,
|
||||
toolbar: '#tb',
|
||||
method: 'get',
|
||||
striped: true,
|
||||
rownumbers: true,
|
||||
onClickCell: onClickCell,
|
||||
onClickRow: onClickRow,
|
||||
onEndEdit: onEndEdit
|
||||
">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-options="field:'a',width:80">动作</th>
|
||||
<th data-options="field:'d',width:80">方向</th>
|
||||
<th data-options="field:'f',width:80,align:'right',editor:{type:'numberbox'}">帧</th>
|
||||
<th data-options="field:'t',width:140,align:'right',editor:{type:'numberbox'}">执行时间(单位:毫秒)</th>
|
||||
<th data-options="field:'e',width:250,editor:'textbox'">事件</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
<div id="tb" style="height:auto">
|
||||
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="append()">添加</a>
|
||||
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeit()">移除</a>
|
||||
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="accept()">应用改动</a>
|
||||
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="reject()">还原改动</a>
|
||||
</div>
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-options="field:'a',width:80">动作</th>
|
||||
<th data-options="field:'d',width:80">方向</th>
|
||||
<th data-options="field:'f',width:80,align:'right',editor:{type:'numberbox'}">帧</th>
|
||||
<th data-options="field:'t',width:140,align:'right',editor:{type:'numberbox'}">执行时间(单位:毫秒)</th>
|
||||
<th data-options="field:'e',width:250,editor:'textbox'">事件</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript">
|
||||
saveCallback = null;
|
||||
var editIndex = undefined;
|
||||
<div id="tb" style="height:auto">
|
||||
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true"
|
||||
onclick="append()">添加</a>
|
||||
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true"
|
||||
onclick="removeit()">移除</a>
|
||||
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true"
|
||||
onclick="accept()">应用改动</a>
|
||||
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true"
|
||||
onclick="reject()">还原改动</a>
|
||||
</div>
|
||||
|
||||
function endEditing() {
|
||||
if (editIndex == undefined) {
|
||||
return true
|
||||
}
|
||||
if ($('#dg').datagrid('validateRow', editIndex)) {
|
||||
$('#dg').datagrid('endEdit', editIndex);
|
||||
editIndex = undefined;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
<div style="float:left">
|
||||
<input type="checkbox" id="chkCircle" disabled="disabled"/> 是否为循环动画 <br/>
|
||||
x偏移: <input id="ox" class="easyui-numberspinner" style="width:80px;" value="0"
|
||||
data-options="min:-1000,max:1000,editable:true"><br/>
|
||||
y偏移: <input id="oy" class="easyui-numberspinner" style="width:80px;" value="0"
|
||||
data-options="min:-1000,max:1000,editable:true"><br/>
|
||||
<a id="btnSaveOffset" href="#" class="easyui-linkbutton">保存偏移</a> <a id="btnCancelOffset" href="#"
|
||||
class="easyui-linkbutton">撤销偏移</a><br/>
|
||||
<br/>
|
||||
逐帧编辑: <input id='frameEdit' class="easyui-switchbutton" data-options="
|
||||
onText:'开启',
|
||||
offText:'关闭',
|
||||
onChange: frameEditChange
|
||||
">
|
||||
<br/><br/>
|
||||
<a id="btnSave" href="#" data-options="iconCls:'icon-save'" class="easyui-linkbutton">保存数据到文件</a>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
saveCallback = null;
|
||||
var editIndex = undefined;
|
||||
frameEdit = false;
|
||||
|
||||
function onClickCell(index, field) {
|
||||
if (editIndex != index) {
|
||||
if (endEditing()) {
|
||||
$('#dg').datagrid('selectRow', index)
|
||||
.datagrid('beginEdit', index);
|
||||
var ed = $('#dg').datagrid('getEditor', {
|
||||
index: index,
|
||||
field: field
|
||||
});
|
||||
if (ed) {
|
||||
($(ed.target).data('textbox') ? $(ed.target).textbox('textbox') : $(ed.target)).focus();
|
||||
}
|
||||
editIndex = index;
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
$('#dg').datagrid('selectRow', editIndex);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
function endEditing() {
|
||||
if (editIndex == undefined) {
|
||||
return true
|
||||
}
|
||||
if ($('#dg').datagrid('validateRow', editIndex)) {
|
||||
$('#dg').datagrid('endEdit', editIndex);
|
||||
editIndex = undefined;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function onEndEdit(index, row) {
|
||||
var ed = $(this).datagrid('getEditor', {
|
||||
index: index,
|
||||
field: 'e'
|
||||
});
|
||||
var tb = $(ed.target);
|
||||
var value = tb.textbox("getValue") || "";
|
||||
tb.textbox("setValue",value.trim());
|
||||
}
|
||||
function onClickCell(index, field) {
|
||||
if (frameEdit) {
|
||||
endEditing();
|
||||
return;
|
||||
}
|
||||
if (editIndex != index) {
|
||||
if (endEditing()) {
|
||||
$('#dg').datagrid('selectRow', index)
|
||||
.datagrid('beginEdit', index);
|
||||
var ed = $('#dg').datagrid('getEditor', {
|
||||
index: index,
|
||||
field: field
|
||||
});
|
||||
if (ed) {
|
||||
($(ed.target).data('textbox') ? $(ed.target).textbox('textbox') : $(ed.target)).focus();
|
||||
}
|
||||
editIndex = index;
|
||||
} else {
|
||||
setTimeout(function () {
|
||||
$('#dg').datagrid('selectRow', editIndex);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function append() {
|
||||
if (endEditing()) {
|
||||
var row = $('#dg').datagrid('getSelected');
|
||||
var idx = -1;
|
||||
if (row) {
|
||||
idx = $('#dg').datagrid("getRowIndex", row);
|
||||
}
|
||||
if (idx > -1) {
|
||||
$('#dg').datagrid("insertRow", {
|
||||
index: idx,
|
||||
row: {
|
||||
a: 0,
|
||||
d: -1
|
||||
}
|
||||
});
|
||||
editIndex = idx;
|
||||
} else {
|
||||
$('#dg').datagrid('appendRow', {
|
||||
a: 0,
|
||||
d: -1
|
||||
});
|
||||
editIndex = $('#dg').datagrid('getRows').length - 1;
|
||||
function onClickRow(index, data) {
|
||||
if (!frameEdit) return;
|
||||
window.frameClicked && window.frameClicked(index);
|
||||
}
|
||||
|
||||
}
|
||||
$('#dg').datagrid('selectRow', editIndex)
|
||||
.datagrid('beginEdit', editIndex);
|
||||
}
|
||||
}
|
||||
function onEndEdit(index, row) {
|
||||
var ed = $(this).datagrid('getEditor', {
|
||||
index: index,
|
||||
field: 'e'
|
||||
});
|
||||
var tb = $(ed.target);
|
||||
var value = tb.textbox('getValue') || '';
|
||||
tb.textbox('setValue', value.trim());
|
||||
}
|
||||
|
||||
function removeit() {
|
||||
if (editIndex == undefined) {
|
||||
return
|
||||
}
|
||||
$('#dg').datagrid('cancelEdit', editIndex)
|
||||
.datagrid('deleteRow', editIndex);
|
||||
editIndex = undefined;
|
||||
}
|
||||
function append() {
|
||||
if (endEditing()) {
|
||||
var row = $('#dg').datagrid('getSelected');
|
||||
var idx = -1;
|
||||
if (row) {
|
||||
idx = $('#dg').datagrid('getRowIndex', row);
|
||||
}
|
||||
if (idx > -1) {
|
||||
$('#dg').datagrid('insertRow', {
|
||||
index: idx,
|
||||
row: {
|
||||
a: 0,
|
||||
d: -1
|
||||
}
|
||||
});
|
||||
editIndex = idx;
|
||||
} else {
|
||||
$('#dg').datagrid('appendRow', {
|
||||
a: 0,
|
||||
d: -1
|
||||
});
|
||||
editIndex = $('#dg').datagrid('getRows').length - 1;
|
||||
|
||||
function accept() {
|
||||
if (endEditing()) {
|
||||
$('#dg').datagrid('acceptChanges');
|
||||
}
|
||||
}
|
||||
}
|
||||
$('#dg').datagrid('selectRow', editIndex)
|
||||
.datagrid('beginEdit', editIndex);
|
||||
}
|
||||
}
|
||||
|
||||
function reject() {
|
||||
$('#dg').datagrid('rejectChanges');
|
||||
editIndex = undefined;
|
||||
}
|
||||
function removeit() {
|
||||
if (editIndex == undefined) {
|
||||
return
|
||||
}
|
||||
$('#dg').datagrid('cancelEdit', editIndex)
|
||||
.datagrid('deleteRow', editIndex);
|
||||
editIndex = undefined;
|
||||
}
|
||||
|
||||
</script>
|
||||
<div style="float:left">
|
||||
<input type="checkbox" id="chkCircle" disabled="disabled" /> 是否为循环动画 <br/>
|
||||
x偏移: <input id="ox" class="easyui-numberspinner" style="width:80px;" value="0" data-options="min:-1000,max:1000,editable:true"><br/>
|
||||
y偏移: <input id="oy" class="easyui-numberspinner" style="width:80px;" value="0" data-options="min:-1000,max:1000,editable:true"><br/>
|
||||
<a id="btnSaveOffset" href="#" class="easyui-linkbutton">保存偏移</a> <a id="btnCancelOffset" href="#" class="easyui-linkbutton">撤销偏移</a><br/>
|
||||
<br/>
|
||||
<a id="btnSave" href="#" data-options="iconCls:'icon-save'" class="easyui-linkbutton">保存数据到文件</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
function accept() {
|
||||
if (endEditing()) {
|
||||
$('#dg').datagrid('acceptChanges');
|
||||
}
|
||||
}
|
||||
|
||||
</html>
|
||||
function reject() {
|
||||
$('#dg').datagrid('rejectChanges');
|
||||
editIndex = undefined;
|
||||
}
|
||||
function setSwitchEnable() {
|
||||
$('#frameEdit').switchbutton('enable');
|
||||
$('#frameEdit').switchbutton('reset');
|
||||
frameEdit = false;
|
||||
$('.panel-header').removeClass('red');
|
||||
}
|
||||
function setSwitchDisable() {
|
||||
$('#frameEdit').switchbutton('disable');
|
||||
}
|
||||
function frameEditChange(e) {
|
||||
frameEdit = e;
|
||||
if (e) {
|
||||
$('.panel-header').addClass('red');
|
||||
window['onStartFrameMode'] && window['onStartFrameMode']();
|
||||
} else {
|
||||
$('.panel-header').removeClass('red');
|
||||
window['onStopFrameMode'] && window['onStopFrameMode']();
|
||||
}
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$('#frameEdit').switchbutton('disable');
|
||||
// $('#frameEdit').switchbutton('check');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
4
run.bat
4
run.bat
@ -1,2 +1,2 @@
|
||||
start /b node web.js
|
||||
electron app
|
||||
#start /b node web.js
|
||||
electron app
|
||||
|
107
src/DragDele.ts
107
src/DragDele.ts
@ -1,91 +1,104 @@
|
||||
module junyou.tools {
|
||||
/**
|
||||
* 拖拽代理
|
||||
* @author 3tion
|
||||
*
|
||||
*/
|
||||
export class DragDele extends egret.Sprite {
|
||||
/**
|
||||
* 拖拽代理
|
||||
* @author 3tion
|
||||
*
|
||||
*/
|
||||
export class DragDele extends egret.Sprite {
|
||||
|
||||
private ox: number;
|
||||
private oy: number;
|
||||
|
||||
private lx: number;
|
||||
private ly: number;
|
||||
|
||||
|
||||
private _offsetChange = this.offsetChange.bind(this);
|
||||
private touching:boolean;
|
||||
|
||||
public aniInfo:junyou.game.AniInfo;
|
||||
private touching: boolean;
|
||||
|
||||
public aniInfo: junyou.game.AniInfo;
|
||||
|
||||
public constructor() {
|
||||
super();
|
||||
let g = this.graphics;
|
||||
g.beginFill(0,0);
|
||||
g.drawRect(-1000,-1000,2000,2000);
|
||||
g.beginFill(0, 0);
|
||||
g.drawRect(-1000, -1000, 2000, 2000);
|
||||
g.endFill();
|
||||
this.touchEnabled = true;
|
||||
this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.tb,this);
|
||||
$(document).ready(()=>{
|
||||
$("#ox")["numberspinner"]({ onChange: this._offsetChange });
|
||||
$("#oy")["numberspinner"]({ onChange: this._offsetChange });
|
||||
$("#btnCancelOffset").on("click",this.cancelHandler.bind(this));
|
||||
$("#btnSaveOffset").on("click",this.saveHandler.bind(this));
|
||||
this.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.tb, this);
|
||||
$(document).ready(() => {
|
||||
$("#ox")["numberspinner"]({onChange: this._offsetChange});
|
||||
$("#oy")["numberspinner"]({onChange: this._offsetChange});
|
||||
$("#btnCancelOffset").on("click", this.cancelHandler.bind(this));
|
||||
$("#btnSaveOffset").on("click", this.saveHandler.bind(this));
|
||||
});
|
||||
}
|
||||
|
||||
private saveHandler(){
|
||||
|
||||
//TODO:: 暂时只编辑单个动画, 如果同时编辑多个, 则需要先判断key
|
||||
private saveHandler() {
|
||||
let dx = this.ox - this.x;
|
||||
let dy = this.oy - this.y;
|
||||
let aniInfo = this.aniInfo;
|
||||
let res = aniInfo.getResource();
|
||||
let datas = res._datas;
|
||||
for( let key in datas){
|
||||
for (let key in datas) {
|
||||
let texes = datas[key];
|
||||
for(let texarr of texes){
|
||||
for(let tex of texarr){
|
||||
tex.tx += dx;
|
||||
tex.ty += dy;
|
||||
for (let texarr of texes) {
|
||||
for (let i = 0; i < texarr.length; i++) {
|
||||
let fdata = texarr[i];
|
||||
if ((junyou.frameMode && junyou.currentFrame != i)) {
|
||||
continue;
|
||||
}
|
||||
fdata.tx += dx;
|
||||
fdata.ty += dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理原始数据 DSW
|
||||
let rawData = aniInfo.rawData[1];
|
||||
// let rawData2 = aniInfo.rawData[0];
|
||||
for(let action in rawData) {
|
||||
for (let action in rawData) {
|
||||
let actData = rawData[action];
|
||||
for(let d = 0,len = actData.length;d < len;d++) {
|
||||
for (let d = 0, len = actData.length; d < len; d++) {
|
||||
let dirData: any[] = actData[d];
|
||||
for(let f = 0,flen = dirData.length;f < flen;f++) {
|
||||
for (let f = 0, flen = dirData.length; f < flen; f++) {
|
||||
let fdata = dirData[f];
|
||||
fdata[2] += dx;
|
||||
fdata[3] += dy;
|
||||
if ((junyou.frameMode && junyou.currentFrame != f)) {
|
||||
continue;
|
||||
}
|
||||
fdata[2] += dx;
|
||||
fdata[3] += dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.cancelHandler();
|
||||
}
|
||||
|
||||
private cancelHandler(){
|
||||
public resetPosition() {
|
||||
this.cancelHandler();
|
||||
}
|
||||
private cancelHandler() {
|
||||
this.x = this.ox;
|
||||
this.y = this.oy;
|
||||
$("#ox")["numberspinner"]("setValue",0);
|
||||
$("#oy")["numberspinner"]("setValue",0);
|
||||
$("#ox")["numberspinner"]("setValue", 0);
|
||||
$("#oy")["numberspinner"]("setValue", 0);
|
||||
}
|
||||
|
||||
|
||||
private offsetChange() {
|
||||
if(!this.touching){
|
||||
if (!this.touching) {
|
||||
var ox = +$("#ox").val();
|
||||
var oy = +$("#oy").val();
|
||||
this.x = this.ox + ox;
|
||||
this.y = this.oy + oy;
|
||||
if (junyou.frameMode) {
|
||||
window['refreshCurrentFrame'] && window['refreshCurrentFrame']();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private tb(e: egret.TouchEvent) {
|
||||
this.lx = e.stageX;
|
||||
this.ly = e.stageY;
|
||||
this.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.tm,this);
|
||||
this.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.te,this);
|
||||
this.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.tm, this);
|
||||
this.stage.addEventListener(egret.TouchEvent.TOUCH_END, this.te, this);
|
||||
this.touching = true;
|
||||
}
|
||||
|
||||
@ -94,28 +107,28 @@ module junyou.tools {
|
||||
let ny = e.stageY;
|
||||
let dx = nx - this.lx;
|
||||
let dy = ny - this.ly;
|
||||
if(dx * dx + dy * dy > 10) {
|
||||
if (dx * dx + dy * dy > 10) {
|
||||
this.lx = nx;
|
||||
this.ly = ny;
|
||||
this.x += dx;
|
||||
this.y += dy;
|
||||
this.y += dy;
|
||||
}
|
||||
}
|
||||
|
||||
private te(e: egret.TouchEvent) {
|
||||
this.stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.tm,this);
|
||||
this.stage.removeEventListener(egret.TouchEvent.TOUCH_END,this.te,this);
|
||||
$("#ox")["numberspinner"]("setValue",this.x - this.ox);
|
||||
$("#oy")["numberspinner"]("setValue",this.y - this.oy);
|
||||
this.stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.tm, this);
|
||||
this.stage.removeEventListener(egret.TouchEvent.TOUCH_END, this.te, this);
|
||||
$("#ox")["numberspinner"]("setValue", this.x - this.ox);
|
||||
$("#oy")["numberspinner"]("setValue", this.y - this.oy);
|
||||
this.touching = false;
|
||||
}
|
||||
|
||||
|
||||
public setStartPoint(sx: number,sy: number) {
|
||||
|
||||
public setStartPoint(sx: number, sy: number) {
|
||||
this.ox = sx;
|
||||
this.oy = sy;
|
||||
this.x = sx;
|
||||
this.y = sy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
39
src/Main.ts
39
src/Main.ts
@ -1,5 +1,9 @@
|
||||
|
||||
import jgame = junyou.game;
|
||||
module junyou {
|
||||
export var frameMode = false;
|
||||
export var currentFrame = 0;
|
||||
}
|
||||
class Main extends egret.DisplayObjectContainer {
|
||||
|
||||
protected currentRender: jgame.AniRender;
|
||||
@ -12,15 +16,46 @@ class Main extends egret.DisplayObjectContainer {
|
||||
|
||||
private dataFile: string;
|
||||
|
||||
|
||||
public constructor() {
|
||||
super();
|
||||
this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
|
||||
window["saveCallback"] = this.saveCallback;
|
||||
let self = this;
|
||||
window["frameClicked"] = function (index) {
|
||||
self.frameClicked(index);
|
||||
};
|
||||
window['onStartFrameMode'] = function () {
|
||||
self.onStartFrameMode();
|
||||
};
|
||||
window['onStopFrameMode'] = function() {
|
||||
self.onStopFrameMode();
|
||||
}
|
||||
window['refreshCurrentFrame'] = function() {
|
||||
self.refreshCurrentFrame();
|
||||
}
|
||||
$(document).ready(() => {
|
||||
$("#btnSave").on("click", this.saveCallback.bind(this));
|
||||
});
|
||||
}
|
||||
|
||||
private onStartFrameMode() {
|
||||
junyou.frameMode = true;
|
||||
this.currentRender.pause();
|
||||
}
|
||||
private onStopFrameMode() {
|
||||
junyou.frameMode = false;
|
||||
junyou.currentFrame = 0;
|
||||
this.currentRender.play();
|
||||
}
|
||||
private frameClicked(frameIndex:number) {
|
||||
console.log('frameClicked', frameIndex);
|
||||
junyou.currentFrame = frameIndex;
|
||||
this.dragDele.resetPosition();
|
||||
this.currentRender.renderFrameIndex(frameIndex);
|
||||
}
|
||||
private refreshCurrentFrame() {
|
||||
this.currentRender.renderFrameIndex(junyou.currentFrame);
|
||||
}
|
||||
private saveCallback() {
|
||||
let pst = this.cPst;
|
||||
let frames = pst.frames;
|
||||
@ -90,6 +125,7 @@ class Main extends egret.DisplayObjectContainer {
|
||||
e.preventDefault();
|
||||
let goted = this.checkFile(e.dataTransfer.files);
|
||||
if (goted) { // 一定是 Electron 环境才能取到值
|
||||
window['setSwitchEnable'] && window['setSwitchEnable']();
|
||||
// 加载数据
|
||||
let require = window["nodeRequire"];
|
||||
let path = require("path");
|
||||
@ -99,6 +135,7 @@ class Main extends egret.DisplayObjectContainer {
|
||||
let rawData = JSON.parse(str);
|
||||
if (goted.pstData) {
|
||||
let pstStr = fs.readFileSync(goted.pstData, "utf8");
|
||||
let pstData = JSON.parse(pstStr);
|
||||
}
|
||||
let aniRender = new jgame.AniRender();
|
||||
let pst = new jgame.AniInfo();
|
||||
|
@ -6,29 +6,29 @@ module junyou.game {
|
||||
*
|
||||
*/
|
||||
export class AniRender extends BaseRender implements IRecyclable{
|
||||
|
||||
|
||||
protected _guid:number;
|
||||
|
||||
|
||||
/**
|
||||
* 特效标识
|
||||
*/
|
||||
public get guid(): number {
|
||||
return this._guid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 显示对象
|
||||
*/
|
||||
public display:ResourceBitmap;
|
||||
|
||||
|
||||
public _aniInfo: AniInfo;
|
||||
|
||||
|
||||
public constructor() {
|
||||
super();
|
||||
// ani动画的动作固定值0
|
||||
this.a = 0;
|
||||
}
|
||||
|
||||
|
||||
protected render(e:Event){
|
||||
var aniInfo = this._aniInfo;
|
||||
var actionInfo = aniInfo.actionInfo;
|
||||
@ -36,35 +36,42 @@ module junyou.game {
|
||||
this.doRender(actionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
renderFrameIndex(index: number) {
|
||||
let aniInfo = this._aniInfo;
|
||||
let actionInfo = aniInfo.actionInfo;
|
||||
let frames = actionInfo.frames;
|
||||
if (index < frames.length) {
|
||||
this.renderFrame(frames[index], Date.now());
|
||||
}
|
||||
}
|
||||
renderFrame(frame: FrameInfo,now: number) {
|
||||
this.f = frame.f;
|
||||
this.display.draw(this,now);
|
||||
}
|
||||
|
||||
|
||||
public play(){
|
||||
this.display.addEventListener(Event.ENTER_FRAME,this.render,this);
|
||||
}
|
||||
|
||||
|
||||
public pause(){
|
||||
this.display.removeEventListener(Event.ENTER_FRAME,this.render,this);
|
||||
}
|
||||
|
||||
public onRecycle(){
|
||||
public onRecycle(){
|
||||
this.display.removeEventListener(Event.ENTER_FRAME,this.render,this);
|
||||
this._aniInfo = null;
|
||||
this._guid = NaN;
|
||||
}
|
||||
|
||||
|
||||
public onSpawn(){
|
||||
this.f = 0;
|
||||
this._playSpeed = 1;
|
||||
}
|
||||
|
||||
|
||||
private static guid = 1;
|
||||
|
||||
|
||||
private static _pool:RecyclablePool<AniRender>=new RecyclablePool(AniRender);
|
||||
|
||||
|
||||
public static getAni(uri:string,display:ResourceBitmap = null){
|
||||
var aniInfo: AniInfo = DataLocator.getData(ConfigKey.ANI)[uri];
|
||||
if(aniInfo){
|
||||
|
@ -11,6 +11,14 @@ module junyou.game {
|
||||
texture.ty = data[3] || 0;
|
||||
var width: number = data[4];
|
||||
var height: number = data[5];
|
||||
if(data.length > 6) {
|
||||
width = data[2];
|
||||
height = data[3];
|
||||
|
||||
texture.tx = data[6] / 2 - data[4];
|
||||
texture.ty = data[7] / 2 - data[5];
|
||||
texture.$initData(sx, sy, width, height, 0, 0, width, height, width, height);
|
||||
}
|
||||
texture.$initData(sx,sy,width,height,0,0,width,height,width,height);
|
||||
return texture;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user