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