Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
game-stydy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
谌继荃
game-stydy
Commits
ffe30319
Commit
ffe30319
authored
Nov 19, 2021
by
谌继荃
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
缓动动画
parent
6b040c15
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
262 deletions
+68
-262
bundle.js
dist/bundle.js
+2
-2
bundle.js
public/bundle.js
+2
-2
drag.ts
src/drag.ts
+0
-256
main.ts
src/main.ts
+2
-2
svga.ts
src/svga.ts
+7
-0
tween.ts
src/tween.ts
+55
-0
No files found.
dist/bundle.js
View file @
ffe30319
...
...
@@ -16,7 +16,7 @@
\*********************/
/***/
((
__unused_webpack_module
,
__webpack_exports__
,
__webpack_require__
)
=>
{
eval
(
"__webpack_require__.r(__webpack_exports__);
\n
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
\n
/* harmony export */
\"
add
DragDemo
\"
: () => (/* binding */ addDragDemo)
\n
/* harmony export */ });
\n
var _this = undefined;
\n
var addDragDemo
= function (stage) {
\n
var gameWrapper = new FYGE.Sprite();
\n
stage.addChild(gameWrapper);
\n
var PIC_URLS = [
\n
'//yun.duiba.com.cn/aurora/assets/cd16134f2544202ed5676adbd5114286aec44347.png',
\n
'//yun.duiba.com.cn/aurora/assets/c55dcd277542a6c3e983278ae5835d89848b9bd9.png',
\n
'//yun.duiba.com.cn/aurora/assets/b42c49baaf8754139d2e940fe97ba1cb289b11fa.png',
\n
'//yun.duiba.com.cn/aurora/assets/4a4b850995da348ccd5fb520d5b9ef5e0fb8349f.png',
\n
'//yun.duiba.com.cn/aurora/assets/5b3e3b52f406df1543e2eeca1ce11719a28c6401.png',
\n
'//yun.duiba.com.cn/aurora/assets/cae0529d1ff2eaa323dc0615d12a1f05e3a67c06.png',
\n
'//yun.duiba.com.cn/aurora/assets/5b91853f9d87de73e319d42ea9df139ddd89d537.png',
\n
'//yun.duiba.com.cn/aurora/assets/a2893c5a0d03ca3252160de1584584e18abe2a4a.png',
\n
'//yun.duiba.com.cn/aurora/assets/c36b0851f61a812e6d745bc205c0551b6590d11d.png',
\n
];
\n
var fill = function (size) {
\n
var list = [];
\n
for (var i = 0; i < size; i++) {
\n
list.push(i);
\n
}
\n
return list;
\n
};
\n
var GAME_SIZE = 3;
\n
var INIT_DATA = fill(GAME_SIZE * GAME_SIZE); //数据为图片id,从0开始(图片索引)
\n
var gamedata = JSON.parse(JSON.stringify(INIT_DATA)); //深拷贝
\n
gamedata.shuffle(); //打乱图片,后续需要和INIT_DATA做对比
\n
console.log('初始打乱的图片数据', gamedata.map(function (i) { return (i + 1); }));
\n
function getIndex(row, col, maxCol) {
\n
var index;
\n
index = row * maxCol + col;
\n
return index;
\n
}
\n
//鼠标按下起始点
\n
var startPoint;
\n
//图片起始位置
\n
var currPicOriginPos;
\n
var currentPic;
\n
var PIC_SIZE = 200;
\n
var GAP = 2;
\n
var onStageMove = function (event) {
\n
//鼠标当前位置
\n
var currentPoint = { x: event.stageX, y: event.stageY };
\n
//鼠标按下点到鼠标当前点的偏移量
\n
var mouseOffsetX = currentPoint.x - startPoint.x;
\n
var mouseOffsetY = currentPoint.y - startPoint.y;
\n
currentPic.x = currPicOriginPos.x + mouseOffsetX;
\n
currentPic.y = currPicOriginPos.y + mouseOffsetY;
\n
};
\n
var onMouseUp_pic = function () {
\n
//鼠标抬起后应该移出舞台移动事件,否则会重复添加事件
\n
gameWrapper.stage.removeEventListener(FYGE.MouseEvent.MOUSE_MOVE, onStageMove, _this);
\n
var picCenterX = currentPic.x + PIC_SIZE / 2;
\n
var picCenterY = currentPic.y + PIC_SIZE / 2;
\n
var dropCol = Math.floor(picCenterX / PIC_SIZE);
\n
var dropRow = Math.floor(picCenterY / PIC_SIZE);
\n
var dropIndex = getIndex(dropRow, dropCol, GAME_SIZE);
\n
console.log('drop index', dropIndex);
\n
var dropId = gamedata[dropIndex];
\n
var dropPic = getPicDisplayById(dropId);
\n
var currentPicId = getPicId(currentPic);
\n
var currentPicIndex = gamedata.indexOf(currentPicId);
\n
console.log('currentPicIndex', currentPicIndex);
\n
console.log('上一个数据', gamedata.map(function (i) { return (i + 1); }));
\n
swap(currentPicIndex, dropIndex, gamedata);
\n
console.log('交换后的数据', gamedata.map(function (i) { return (i + 1); }));
\n
currentPic.x = dropPic.x;
\n
currentPic.y = dropPic.y;
\n
dropPic.x = currPicOriginPos.x;
\n
dropPic.y = currPicOriginPos.y;
\n
if (equalTo(INIT_DATA, gamedata)) {
\n
setTimeout(function () {
\n
alert('哈哈,赢了');
\n
}, 500);
\n
}
\n
};
\n
var onMouseDown_picItem = function (event) {
\n
currentPic = event.target;
\n
//图片鼠标弹起事件,事件触发一次即移除,否则会重复添加鼠标弹起事件
\n
currentPic.once(FYGE.MouseEvent.MOUSE_UP, onMouseUp_pic, _this);
\n
//添加舞台移动事件,鼠标移动即触发
\n
//FYGE.MouseEvent.MOUSE_MOVE 会在鼠标移动过程中触发
\n
gameWrapper.stage.addEventListener(FYGE.MouseEvent.MOUSE_MOVE, onStageMove, _this);
\n
//event事件对象
\n
//event.stageX,event.stageY当前鼠标在舞台的位置
\n
startPoint = { x: event.stageX, y: event.stageY };
\n
currPicOriginPos = { x: currentPic.x, y: currentPic.y };
\n
gameWrapper.addChild(currentPic); //把当前图片移动到最上层
\n
};
\n
var PIC_DISPLAY_LIST = INIT_DATA.map(function (data) { return FYGE.Sprite.fromUrl(PIC_URLS[data]); }); //图片视图数据(列表)
\n
var getPicDisplayById = function (id) { return PIC_DISPLAY_LIST[id]; }; //获取视图数据方法
\n
var getPicId = function (picDisplay) {
\n
for (var i = 0; i < PIC_DISPLAY_LIST.length; i++) {
\n
var element = PIC_DISPLAY_LIST[i];
\n
if (element == picDisplay)
\n
return i;
\n
}
\n
return -1;
\n
}; //你会看到用索引的好处
\n
var equalTo = function (array1, array2) {
\n
if (array1.length != array1.length)
\n
return false;
\n
var len = array1.length || array1.length;
\n
for (var i = 0; i < len; i++) {
\n
var a = array1[i];
\n
var b = array2[i];
\n
if (a != b)
\n
return false;
\n
}
\n
return true;
\n
}; //判断数组是否相等
\n
//数组元素交换
\n
var swap = function (index1, index2, list) {
\n
var ele1 = list[index1];
\n
var ele2 = list[index2];
\n
list[index1] = ele2;
\n
list[index2] = ele1;
\n
return list;
\n
};
\n
//生成游戏
\n
gamedata.map(function (data, index) {
\n
var picItem = gameWrapper.addChild(getPicDisplayById(data));
\n
var col = index % GAME_SIZE;
\n
var row = Math.floor(index / GAME_SIZE);
\n
picItem.x = col * (PIC_SIZE + GAP);
\n
picItem.y = row * (PIC_SIZE + GAP);
\n
//增加鼠标按下事件
\n
picItem.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, onMouseDown_picItem, _this);
\n
return picItem;
\n
});
\n
};
\n\n\n
//# sourceURL=webpack:///./src/drag.ts?"
);
eval
(
"__webpack_require__.r(__webpack_exports__);
\n
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
\n
/* harmony export */
\"
add
Tween
\"
: () => (/* binding */ addTween)
\n
/* harmony export */ });
\n
var _this = undefined;
\n
var addTween
= function (stage) {
\n
var gameWrapper = new FYGE.Sprite();
\n
stage.addChild(gameWrapper);
\n
var PIC_URLS = [
\n
'//yun.duiba.com.cn/aurora/assets/cd16134f2544202ed5676adbd5114286aec44347.png',
\n
'//yun.duiba.com.cn/aurora/assets/c55dcd277542a6c3e983278ae5835d89848b9bd9.png',
\n
'//yun.duiba.com.cn/aurora/assets/b42c49baaf8754139d2e940fe97ba1cb289b11fa.png',
\n
'//yun.duiba.com.cn/aurora/assets/4a4b850995da348ccd5fb520d5b9ef5e0fb8349f.png',
\n
'//yun.duiba.com.cn/aurora/assets/5b3e3b52f406df1543e2eeca1ce11719a28c6401.png',
\n
'//yun.duiba.com.cn/aurora/assets/cae0529d1ff2eaa323dc0615d12a1f05e3a67c06.png',
\n
'//yun.duiba.com.cn/aurora/assets/5b91853f9d87de73e319d42ea9df139ddd89d537.png',
\n
'//yun.duiba.com.cn/aurora/assets/a2893c5a0d03ca3252160de1584584e18abe2a4a.png',
\n
'//yun.duiba.com.cn/aurora/assets/c36b0851f61a812e6d745bc205c0551b6590d11d.png',
\n
];
\n
var fill = function (size) {
\n
var list = [];
\n
for (var i = 0; i < size; i++) {
\n
list.push(i);
\n
}
\n
return list;
\n
};
\n
var GAME_SIZE = 3;
\n
var INIT_DATA = fill(GAME_SIZE * GAME_SIZE); //数据为图片id,从0开始(图片索引)
\n
var gamedata = JSON.parse(JSON.stringify(INIT_DATA)); //深拷贝
\n
gamedata.shuffle(); //打乱图片,后续需要和INIT_DATA做对比
\n
console.log('初始打乱的图片数据', gamedata.map(function (i) { return (i + 1); }));
\n
function getIndex(row, col, maxCol) {
\n
var index;
\n
index = row * maxCol + col;
\n
return index;
\n
}
\n
//鼠标按下起始点
\n
var startPoint;
\n
//图片起始位置
\n
var currPicOriginPos;
\n
var currentPic;
\n
var PIC_SIZE = 200;
\n
var GAP = 2;
\n
var onStageMove = function (event) {
\n
//鼠标当前位置
\n
var currentPoint = { x: event.stageX, y: event.stageY };
\n
//鼠标按下点到鼠标当前点的偏移量
\n
var mouseOffsetX = currentPoint.x - startPoint.x;
\n
var mouseOffsetY = currentPoint.y - startPoint.y;
\n
currentPic.x = currPicOriginPos.x + mouseOffsetX;
\n
currentPic.y = currPicOriginPos.y + mouseOffsetY;
\n
};
\n
var onMouseUp_pic = function () {
\n
//鼠标抬起后应该移出舞台移动事件,否则会重复添加事件
\n
gameWrapper.stage.removeEventListener(FYGE.MouseEvent.MOUSE_MOVE, onStageMove, _this);
\n
var picCenterX = currentPic.x + PIC_SIZE / 2;
\n
var picCenterY = currentPic.y + PIC_SIZE / 2;
\n
var dropCol = Math.floor(picCenterX / PIC_SIZE);
\n
var dropRow = Math.floor(picCenterY / PIC_SIZE);
\n
var dropIndex = getIndex(dropRow, dropCol, GAME_SIZE);
\n
console.log('drop index', dropIndex);
\n
var dropId = gamedata[dropIndex];
\n
var dropPic = getPicDisplayById(dropId);
\n
var currentPicId = getPicId(currentPic);
\n
var currentPicIndex = gamedata.indexOf(currentPicId);
\n
console.log('currentPicIndex', currentPicIndex);
\n
console.log('上一个数据', gamedata.map(function (i) { return (i + 1); }));
\n
swap(currentPicIndex, dropIndex, gamedata);
\n
console.log('交换后的数据', gamedata.map(function (i) { return (i + 1); }));
\n
currentPic.x = dropPic.x;
\n
currentPic.y = dropPic.y;
\n
dropPic.x = currPicOriginPos.x;
\n
dropPic.y = currPicOriginPos.y;
\n
if (equalTo(INIT_DATA, gamedata)) {
\n
setTimeout(function () {
\n
alert('哈哈,赢了');
\n
}, 500);
\n
}
\n
};
\n
var onMouseDown_picItem = function (event) {
\n
currentPic = event.target;
\n
//图片鼠标弹起事件,事件触发一次即移除,否则会重复添加鼠标弹起事件
\n
currentPic.once(FYGE.MouseEvent.MOUSE_UP, onMouseUp_pic, _this);
\n
//添加舞台移动事件,鼠标移动即触发
\n
//FYGE.MouseEvent.MOUSE_MOVE 会在鼠标移动过程中触发
\n
gameWrapper.stage.addEventListener(FYGE.MouseEvent.MOUSE_MOVE, onStageMove, _this);
\n
//event事件对象
\n
//event.stageX,event.stageY当前鼠标在舞台的位置
\n
startPoint = { x: event.stageX, y: event.stageY };
\n
currPicOriginPos = { x: currentPic.x, y: currentPic.y };
\n
gameWrapper.addChild(currentPic); //把当前图片移动到最上层
\n
};
\n
var PIC_DISPLAY_LIST = INIT_DATA.map(function (data) { return FYGE.Sprite.fromUrl(PIC_URLS[data]); }); //图片视图数据(列表)
\n
var getPicDisplayById = function (id) { return PIC_DISPLAY_LIST[id]; }; //获取视图数据方法
\n
var getPicId = function (picDisplay) {
\n
for (var i = 0; i < PIC_DISPLAY_LIST.length; i++) {
\n
var element = PIC_DISPLAY_LIST[i];
\n
if (element == picDisplay)
\n
return i;
\n
}
\n
return -1;
\n
}; //你会看到用索引的好处
\n
var equalTo = function (array1, array2) {
\n
if (array1.length != array1.length)
\n
return false;
\n
var len = array1.length || array1.length;
\n
for (var i = 0; i < len; i++) {
\n
var a = array1[i];
\n
var b = array2[i];
\n
if (a != b)
\n
return false;
\n
}
\n
return true;
\n
}; //判断数组是否相等
\n
//数组元素交换
\n
var swap = function (index1, index2, list) {
\n
var ele1 = list[index1];
\n
var ele2 = list[index2];
\n
list[index1] = ele2;
\n
list[index2] = ele1;
\n
return list;
\n
};
\n
//生成游戏
\n
gamedata.map(function (data, index) {
\n
var picItem = gameWrapper.addChild(getPicDisplayById(data));
\n
var col = index % GAME_SIZE;
\n
var row = Math.floor(index / GAME_SIZE);
\n
picItem.x = col * (PIC_SIZE + GAP);
\n
picItem.y = row * (PIC_SIZE + GAP);
\n
//增加鼠标按下事件
\n
picItem.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, onMouseDown_picItem, _this);
\n
return picItem;
\n
});
\n
};
\n\n\n
//# sourceURL=webpack:///./src/drag.ts?"
);
/***/
}),
...
...
@@ -26,7 +26,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
\*********************/
/***/
((
__unused_webpack_module
,
__webpack_exports__
,
__webpack_require__
)
=>
{
eval
(
"__webpack_require__.r(__webpack_exports__);
\n
/* harmony import */ var _drag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./drag */
\"
./src/drag.ts
\"
);
\n\n
var canvas = document.getElementById(
\"
canvas
\"
);
\n
canvas.width = document.body.clientWidth * 1;
\n
canvas.height = document.body.clientHeight * 1;
\n
var stage = new FYGE.Stage(canvas, 750, 1624, canvas.width, canvas.height, FYGE.RENDERER_TYPE.CANVAS, false, false);
\n
var mouseEvent = stage.onMouseEvent.bind(stage);
\n
canvas.addEventListener(
\"
touchstart
\"
, mouseEvent, false);
\n
canvas.addEventListener('touchmove', mouseEvent, false);
\n
canvas.addEventListener('touchend', mouseEvent, false);
\n
stage.addEventListener(FYGE.Event.INIT_STAGE, onInitStage, undefined);
\n
function onInitStage() {
\n
(0,_drag__WEBPACK_IMPORTED_MODULE_0__.add
DragDemo
)(stage);
\n
}
\n
(function loop() {
\n
FYGE.Tween.flush();
\n
stage.flush();
\n
requestAnimationFrame(loop);
\n
})();
\n\n\n
//# sourceURL=webpack:///./src/main.ts?"
);
eval
(
"__webpack_require__.r(__webpack_exports__);
\n
/* harmony import */ var _drag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./drag */
\"
./src/drag.ts
\"
);
\n\n
var canvas = document.getElementById(
\"
canvas
\"
);
\n
canvas.width = document.body.clientWidth * 1;
\n
canvas.height = document.body.clientHeight * 1;
\n
var stage = new FYGE.Stage(canvas, 750, 1624, canvas.width, canvas.height, FYGE.RENDERER_TYPE.CANVAS, false, false);
\n
var mouseEvent = stage.onMouseEvent.bind(stage);
\n
canvas.addEventListener(
\"
touchstart
\"
, mouseEvent, false);
\n
canvas.addEventListener('touchmove', mouseEvent, false);
\n
canvas.addEventListener('touchend', mouseEvent, false);
\n
stage.addEventListener(FYGE.Event.INIT_STAGE, onInitStage, undefined);
\n
function onInitStage() {
\n
(0,_drag__WEBPACK_IMPORTED_MODULE_0__.add
Tween
)(stage);
\n
}
\n
(function loop() {
\n
FYGE.Tween.flush();
\n
stage.flush();
\n
requestAnimationFrame(loop);
\n
})();
\n\n\n
//# sourceURL=webpack:///./src/main.ts?"
);
/***/
})
...
...
public/bundle.js
View file @
ffe30319
...
...
@@ -16,7 +16,7 @@
\*********************/
/***/
((
__unused_webpack_module
,
__webpack_exports__
,
__webpack_require__
)
=>
{
eval
(
"__webpack_require__.r(__webpack_exports__);
\n
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
\n
/* harmony export */
\"
add
DragDemo
\"
: () => (/* binding */ addDragDemo)
\n
/* harmony export */ });
\n
var _this = undefined;
\n
var addDragDemo
= function (stage) {
\n
var gameWrapper = new FYGE.Sprite();
\n
stage.addChild(gameWrapper);
\n
var PIC_URLS = [
\n
'//yun.duiba.com.cn/aurora/assets/cd16134f2544202ed5676adbd5114286aec44347.png',
\n
'//yun.duiba.com.cn/aurora/assets/c55dcd277542a6c3e983278ae5835d89848b9bd9.png',
\n
'//yun.duiba.com.cn/aurora/assets/b42c49baaf8754139d2e940fe97ba1cb289b11fa.png',
\n
'//yun.duiba.com.cn/aurora/assets/4a4b850995da348ccd5fb520d5b9ef5e0fb8349f.png',
\n
'//yun.duiba.com.cn/aurora/assets/5b3e3b52f406df1543e2eeca1ce11719a28c6401.png',
\n
'//yun.duiba.com.cn/aurora/assets/cae0529d1ff2eaa323dc0615d12a1f05e3a67c06.png',
\n
'//yun.duiba.com.cn/aurora/assets/5b91853f9d87de73e319d42ea9df139ddd89d537.png',
\n
'//yun.duiba.com.cn/aurora/assets/a2893c5a0d03ca3252160de1584584e18abe2a4a.png',
\n
'//yun.duiba.com.cn/aurora/assets/c36b0851f61a812e6d745bc205c0551b6590d11d.png',
\n
];
\n
var fill = function (size) {
\n
var list = [];
\n
for (var i = 0; i < size; i++) {
\n
list.push(i);
\n
}
\n
return list;
\n
};
\n
var GAME_SIZE = 3;
\n
var INIT_DATA = fill(GAME_SIZE * GAME_SIZE); //数据为图片id,从0开始(图片索引)
\n
var gamedata = JSON.parse(JSON.stringify(INIT_DATA)); //深拷贝
\n
gamedata.shuffle(); //打乱图片,后续需要和INIT_DATA做对比
\n
console.log('初始打乱的图片数据', gamedata.map(function (i) { return (i + 1); }));
\n
function getIndex(row, col, maxCol) {
\n
var index;
\n
index = row * maxCol + col;
\n
return index;
\n
}
\n
//鼠标按下起始点
\n
var startPoint;
\n
//图片起始位置
\n
var currPicOriginPos;
\n
var currentPic;
\n
var PIC_SIZE = 200;
\n
var GAP = 2;
\n
var onStageMove = function (event) {
\n
//鼠标当前位置
\n
var currentPoint = { x: event.stageX, y: event.stageY };
\n
//鼠标按下点到鼠标当前点的偏移量
\n
var mouseOffsetX = currentPoint.x - startPoint.x;
\n
var mouseOffsetY = currentPoint.y - startPoint.y;
\n
currentPic.x = currPicOriginPos.x + mouseOffsetX;
\n
currentPic.y = currPicOriginPos.y + mouseOffsetY;
\n
};
\n
var onMouseUp_pic = function () {
\n
//鼠标抬起后应该移出舞台移动事件,否则会重复添加事件
\n
gameWrapper.stage.removeEventListener(FYGE.MouseEvent.MOUSE_MOVE, onStageMove, _this);
\n
var picCenterX = currentPic.x + PIC_SIZE / 2;
\n
var picCenterY = currentPic.y + PIC_SIZE / 2;
\n
var dropCol = Math.floor(picCenterX / PIC_SIZE);
\n
var dropRow = Math.floor(picCenterY / PIC_SIZE);
\n
var dropIndex = getIndex(dropRow, dropCol, GAME_SIZE);
\n
console.log('drop index', dropIndex);
\n
var dropId = gamedata[dropIndex];
\n
var dropPic = getPicDisplayById(dropId);
\n
var currentPicId = getPicId(currentPic);
\n
var currentPicIndex = gamedata.indexOf(currentPicId);
\n
console.log('currentPicIndex', currentPicIndex);
\n
console.log('上一个数据', gamedata.map(function (i) { return (i + 1); }));
\n
swap(currentPicIndex, dropIndex, gamedata);
\n
console.log('交换后的数据', gamedata.map(function (i) { return (i + 1); }));
\n
currentPic.x = dropPic.x;
\n
currentPic.y = dropPic.y;
\n
dropPic.x = currPicOriginPos.x;
\n
dropPic.y = currPicOriginPos.y;
\n
if (equalTo(INIT_DATA, gamedata)) {
\n
setTimeout(function () {
\n
alert('哈哈,赢了');
\n
}, 500);
\n
}
\n
};
\n
var onMouseDown_picItem = function (event) {
\n
currentPic = event.target;
\n
//图片鼠标弹起事件,事件触发一次即移除,否则会重复添加鼠标弹起事件
\n
currentPic.once(FYGE.MouseEvent.MOUSE_UP, onMouseUp_pic, _this);
\n
//添加舞台移动事件,鼠标移动即触发
\n
//FYGE.MouseEvent.MOUSE_MOVE 会在鼠标移动过程中触发
\n
gameWrapper.stage.addEventListener(FYGE.MouseEvent.MOUSE_MOVE, onStageMove, _this);
\n
//event事件对象
\n
//event.stageX,event.stageY当前鼠标在舞台的位置
\n
startPoint = { x: event.stageX, y: event.stageY };
\n
currPicOriginPos = { x: currentPic.x, y: currentPic.y };
\n
gameWrapper.addChild(currentPic); //把当前图片移动到最上层
\n
};
\n
var PIC_DISPLAY_LIST = INIT_DATA.map(function (data) { return FYGE.Sprite.fromUrl(PIC_URLS[data]); }); //图片视图数据(列表)
\n
var getPicDisplayById = function (id) { return PIC_DISPLAY_LIST[id]; }; //获取视图数据方法
\n
var getPicId = function (picDisplay) {
\n
for (var i = 0; i < PIC_DISPLAY_LIST.length; i++) {
\n
var element = PIC_DISPLAY_LIST[i];
\n
if (element == picDisplay)
\n
return i;
\n
}
\n
return -1;
\n
}; //你会看到用索引的好处
\n
var equalTo = function (array1, array2) {
\n
if (array1.length != array1.length)
\n
return false;
\n
var len = array1.length || array1.length;
\n
for (var i = 0; i < len; i++) {
\n
var a = array1[i];
\n
var b = array2[i];
\n
if (a != b)
\n
return false;
\n
}
\n
return true;
\n
}; //判断数组是否相等
\n
//数组元素交换
\n
var swap = function (index1, index2, list) {
\n
var ele1 = list[index1];
\n
var ele2 = list[index2];
\n
list[index1] = ele2;
\n
list[index2] = ele1;
\n
return list;
\n
};
\n
//生成游戏
\n
gamedata.map(function (data, index) {
\n
var picItem = gameWrapper.addChild(getPicDisplayById(data));
\n
var col = index % GAME_SIZE;
\n
var row = Math.floor(index / GAME_SIZE);
\n
picItem.x = col * (PIC_SIZE + GAP);
\n
picItem.y = row * (PIC_SIZE + GAP);
\n
//增加鼠标按下事件
\n
picItem.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, onMouseDown_picItem, _this);
\n
return picItem;
\n
});
\n
};
\n\n\n
//# sourceURL=webpack:///./src/drag.ts?"
);
eval
(
"__webpack_require__.r(__webpack_exports__);
\n
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
\n
/* harmony export */
\"
add
Tween
\"
: () => (/* binding */ addTween)
\n
/* harmony export */ });
\n
var _this = undefined;
\n
var addTween
= function (stage) {
\n
var gameWrapper = new FYGE.Sprite();
\n
stage.addChild(gameWrapper);
\n
var PIC_URLS = [
\n
'//yun.duiba.com.cn/aurora/assets/cd16134f2544202ed5676adbd5114286aec44347.png',
\n
'//yun.duiba.com.cn/aurora/assets/c55dcd277542a6c3e983278ae5835d89848b9bd9.png',
\n
'//yun.duiba.com.cn/aurora/assets/b42c49baaf8754139d2e940fe97ba1cb289b11fa.png',
\n
'//yun.duiba.com.cn/aurora/assets/4a4b850995da348ccd5fb520d5b9ef5e0fb8349f.png',
\n
'//yun.duiba.com.cn/aurora/assets/5b3e3b52f406df1543e2eeca1ce11719a28c6401.png',
\n
'//yun.duiba.com.cn/aurora/assets/cae0529d1ff2eaa323dc0615d12a1f05e3a67c06.png',
\n
'//yun.duiba.com.cn/aurora/assets/5b91853f9d87de73e319d42ea9df139ddd89d537.png',
\n
'//yun.duiba.com.cn/aurora/assets/a2893c5a0d03ca3252160de1584584e18abe2a4a.png',
\n
'//yun.duiba.com.cn/aurora/assets/c36b0851f61a812e6d745bc205c0551b6590d11d.png',
\n
];
\n
var fill = function (size) {
\n
var list = [];
\n
for (var i = 0; i < size; i++) {
\n
list.push(i);
\n
}
\n
return list;
\n
};
\n
var GAME_SIZE = 3;
\n
var INIT_DATA = fill(GAME_SIZE * GAME_SIZE); //数据为图片id,从0开始(图片索引)
\n
var gamedata = JSON.parse(JSON.stringify(INIT_DATA)); //深拷贝
\n
gamedata.shuffle(); //打乱图片,后续需要和INIT_DATA做对比
\n
console.log('初始打乱的图片数据', gamedata.map(function (i) { return (i + 1); }));
\n
function getIndex(row, col, maxCol) {
\n
var index;
\n
index = row * maxCol + col;
\n
return index;
\n
}
\n
//鼠标按下起始点
\n
var startPoint;
\n
//图片起始位置
\n
var currPicOriginPos;
\n
var currentPic;
\n
var PIC_SIZE = 200;
\n
var GAP = 2;
\n
var onStageMove = function (event) {
\n
//鼠标当前位置
\n
var currentPoint = { x: event.stageX, y: event.stageY };
\n
//鼠标按下点到鼠标当前点的偏移量
\n
var mouseOffsetX = currentPoint.x - startPoint.x;
\n
var mouseOffsetY = currentPoint.y - startPoint.y;
\n
currentPic.x = currPicOriginPos.x + mouseOffsetX;
\n
currentPic.y = currPicOriginPos.y + mouseOffsetY;
\n
};
\n
var onMouseUp_pic = function () {
\n
//鼠标抬起后应该移出舞台移动事件,否则会重复添加事件
\n
gameWrapper.stage.removeEventListener(FYGE.MouseEvent.MOUSE_MOVE, onStageMove, _this);
\n
var picCenterX = currentPic.x + PIC_SIZE / 2;
\n
var picCenterY = currentPic.y + PIC_SIZE / 2;
\n
var dropCol = Math.floor(picCenterX / PIC_SIZE);
\n
var dropRow = Math.floor(picCenterY / PIC_SIZE);
\n
var dropIndex = getIndex(dropRow, dropCol, GAME_SIZE);
\n
console.log('drop index', dropIndex);
\n
var dropId = gamedata[dropIndex];
\n
var dropPic = getPicDisplayById(dropId);
\n
var currentPicId = getPicId(currentPic);
\n
var currentPicIndex = gamedata.indexOf(currentPicId);
\n
console.log('currentPicIndex', currentPicIndex);
\n
console.log('上一个数据', gamedata.map(function (i) { return (i + 1); }));
\n
swap(currentPicIndex, dropIndex, gamedata);
\n
console.log('交换后的数据', gamedata.map(function (i) { return (i + 1); }));
\n
currentPic.x = dropPic.x;
\n
currentPic.y = dropPic.y;
\n
dropPic.x = currPicOriginPos.x;
\n
dropPic.y = currPicOriginPos.y;
\n
if (equalTo(INIT_DATA, gamedata)) {
\n
setTimeout(function () {
\n
alert('哈哈,赢了');
\n
}, 500);
\n
}
\n
};
\n
var onMouseDown_picItem = function (event) {
\n
currentPic = event.target;
\n
//图片鼠标弹起事件,事件触发一次即移除,否则会重复添加鼠标弹起事件
\n
currentPic.once(FYGE.MouseEvent.MOUSE_UP, onMouseUp_pic, _this);
\n
//添加舞台移动事件,鼠标移动即触发
\n
//FYGE.MouseEvent.MOUSE_MOVE 会在鼠标移动过程中触发
\n
gameWrapper.stage.addEventListener(FYGE.MouseEvent.MOUSE_MOVE, onStageMove, _this);
\n
//event事件对象
\n
//event.stageX,event.stageY当前鼠标在舞台的位置
\n
startPoint = { x: event.stageX, y: event.stageY };
\n
currPicOriginPos = { x: currentPic.x, y: currentPic.y };
\n
gameWrapper.addChild(currentPic); //把当前图片移动到最上层
\n
};
\n
var PIC_DISPLAY_LIST = INIT_DATA.map(function (data) { return FYGE.Sprite.fromUrl(PIC_URLS[data]); }); //图片视图数据(列表)
\n
var getPicDisplayById = function (id) { return PIC_DISPLAY_LIST[id]; }; //获取视图数据方法
\n
var getPicId = function (picDisplay) {
\n
for (var i = 0; i < PIC_DISPLAY_LIST.length; i++) {
\n
var element = PIC_DISPLAY_LIST[i];
\n
if (element == picDisplay)
\n
return i;
\n
}
\n
return -1;
\n
}; //你会看到用索引的好处
\n
var equalTo = function (array1, array2) {
\n
if (array1.length != array1.length)
\n
return false;
\n
var len = array1.length || array1.length;
\n
for (var i = 0; i < len; i++) {
\n
var a = array1[i];
\n
var b = array2[i];
\n
if (a != b)
\n
return false;
\n
}
\n
return true;
\n
}; //判断数组是否相等
\n
//数组元素交换
\n
var swap = function (index1, index2, list) {
\n
var ele1 = list[index1];
\n
var ele2 = list[index2];
\n
list[index1] = ele2;
\n
list[index2] = ele1;
\n
return list;
\n
};
\n
//生成游戏
\n
gamedata.map(function (data, index) {
\n
var picItem = gameWrapper.addChild(getPicDisplayById(data));
\n
var col = index % GAME_SIZE;
\n
var row = Math.floor(index / GAME_SIZE);
\n
picItem.x = col * (PIC_SIZE + GAP);
\n
picItem.y = row * (PIC_SIZE + GAP);
\n
//增加鼠标按下事件
\n
picItem.addEventListener(FYGE.MouseEvent.MOUSE_DOWN, onMouseDown_picItem, _this);
\n
return picItem;
\n
});
\n
};
\n\n\n
//# sourceURL=webpack:///./src/drag.ts?"
);
/***/
}),
...
...
@@ -26,7 +26,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
\*********************/
/***/
((
__unused_webpack_module
,
__webpack_exports__
,
__webpack_require__
)
=>
{
eval
(
"__webpack_require__.r(__webpack_exports__);
\n
/* harmony import */ var _drag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./drag */
\"
./src/drag.ts
\"
);
\n\n
var canvas = document.getElementById(
\"
canvas
\"
);
\n
canvas.width = document.body.clientWidth * 1;
\n
canvas.height = document.body.clientHeight * 1;
\n
var stage = new FYGE.Stage(canvas, 750, 1624, canvas.width, canvas.height, FYGE.RENDERER_TYPE.CANVAS, false, false);
\n
var mouseEvent = stage.onMouseEvent.bind(stage);
\n
canvas.addEventListener(
\"
touchstart
\"
, mouseEvent, false);
\n
canvas.addEventListener('touchmove', mouseEvent, false);
\n
canvas.addEventListener('touchend', mouseEvent, false);
\n
stage.addEventListener(FYGE.Event.INIT_STAGE, onInitStage, undefined);
\n
function onInitStage() {
\n
(0,_drag__WEBPACK_IMPORTED_MODULE_0__.add
DragDemo
)(stage);
\n
}
\n
(function loop() {
\n
FYGE.Tween.flush();
\n
stage.flush();
\n
requestAnimationFrame(loop);
\n
})();
\n\n\n
//# sourceURL=webpack:///./src/main.ts?"
);
eval
(
"__webpack_require__.r(__webpack_exports__);
\n
/* harmony import */ var _drag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./drag */
\"
./src/drag.ts
\"
);
\n\n
var canvas = document.getElementById(
\"
canvas
\"
);
\n
canvas.width = document.body.clientWidth * 1;
\n
canvas.height = document.body.clientHeight * 1;
\n
var stage = new FYGE.Stage(canvas, 750, 1624, canvas.width, canvas.height, FYGE.RENDERER_TYPE.CANVAS, false, false);
\n
var mouseEvent = stage.onMouseEvent.bind(stage);
\n
canvas.addEventListener(
\"
touchstart
\"
, mouseEvent, false);
\n
canvas.addEventListener('touchmove', mouseEvent, false);
\n
canvas.addEventListener('touchend', mouseEvent, false);
\n
stage.addEventListener(FYGE.Event.INIT_STAGE, onInitStage, undefined);
\n
function onInitStage() {
\n
(0,_drag__WEBPACK_IMPORTED_MODULE_0__.add
Tween
)(stage);
\n
}
\n
(function loop() {
\n
FYGE.Tween.flush();
\n
stage.flush();
\n
requestAnimationFrame(loop);
\n
})();
\n\n\n
//# sourceURL=webpack:///./src/main.ts?"
);
/***/
})
...
...
src/drag.ts
deleted
100644 → 0
View file @
6b040c15
import
{
equalTo
,
fill
,
shuffle
,
swap
,
getIndex
}
from
"./util"
;
import
{
GAME_SIZE
,
GAME_SIZE2
,
PIC_URLS
}
from
"./gameconfig"
;
export
const
addDragDemo
=
(
stage
:
FYGE
.
Stage
)
=>
{
let
startGameText
=
"开始游戏"
;
let
startFlag
=
false
;
let
goneStep
=
0
;
let
gameDuration
=
60
;
let
timer
=
null
;
const
gameWrapper
=
new
FYGE
.
Sprite
();
let
startGame
=
new
FYGE
.
TextField
();
let
goneStepText
=
new
FYGE
.
TextField
();
let
countDownText
=
new
FYGE
.
TextField
();
stage
.
addChild
(
gameWrapper
);
const
onShuffle
=
()
=>
{
shuffle
(
gamedata
);
// 随机到正确答案后应该再随机一次
if
(
equalTo
(
INIT_DATA
,
gamedata
))
{
shuffle
(
gamedata
);
}
};
const
reset
=
()
=>
{
goneStep
=
0
;
gameDuration
=
60
;
clearInterval
(
timer
);
timer
=
null
;
stage
.
removeChildren
(
countDownText
,
goneStepText
);
startFlag
=
true
;
startGameText
=
"重新开始"
;
};
const
onStartGame
=
()
=>
{
// 清除点击事件
startGame
.
removeEventListener
(
FYGE
.
MouseEvent
.
CLICK
,
onStartGame
,
this
);
console
.
log
(
"startGameText"
,
startGameText
);
reset
();
renderGoneStep
();
countDown
();
onShuffle
();
//打乱图片,后续需要和INIT_DATA做对比
renderGame
();
addStartGameBtn
();
};
// 开始游戏按钮
const
addStartGameBtn
=
()
=>
{
startGame
.
text
=
startGameText
;
startGame
.
fillColor
=
"#000000"
;
startGame
.
size
=
50
;
startGame
.
x
=
250
;
startGame
.
y
=
700
;
startGame
.
addEventListener
(
FYGE
.
MouseEvent
.
CLICK
,
onStartGame
,
this
);
stage
.
addChild
(
startGame
);
};
addStartGameBtn
();
// 当前已走
const
renderGoneStep
=
()
=>
{
if
(
goneStep
>
0
)
{
goneStepText
.
text
=
`当前已走
${
goneStep
}
步`
;
goneStepText
.
fillColor
=
"#000000"
;
goneStepText
.
size
=
50
;
goneStepText
.
x
=
225
;
goneStepText
.
y
=
800
;
stage
.
addChild
(
goneStepText
);
}
};
renderGoneStep
();
const
countDown
=
()
=>
{
timer
=
setInterval
(
async
()
=>
{
if
(
gameDuration
===
0
)
{
clearInterval
(
timer
);
timer
=
null
;
startFlag
=
false
;
alert
(
"游戏结束"
);
stage
.
removeChild
(
countDownText
);
}
else
{
gameDuration
-=
1
;
renderCountDown
();
}
},
1000
);
};
// 倒计时
const
renderCountDown
=
()
=>
{
countDownText
.
text
=
`还剩
${
gameDuration
}
s`
;
countDownText
.
fillColor
=
"#000000"
;
countDownText
.
size
=
50
;
countDownText
.
x
=
275
;
countDownText
.
y
=
900
;
stage
.
addChild
(
countDownText
);
};
const
INIT_DATA
:
any
=
fill
(
GAME_SIZE
*
GAME_SIZE2
);
//数据为图片id,从0开始(图片索引)
let
gamedata
=
JSON
.
parse
(
JSON
.
stringify
(
INIT_DATA
));
//深拷贝
console
.
log
(
"初始打乱的图片数据"
,
gamedata
.
map
((
i
)
=>
i
+
1
)
);
//鼠标按下起始点
let
startPoint
;
//图片起始位置
let
currPicOriginPos
;
// DisplayObject 显示对象类。
let
currentPic
:
FYGE
.
DisplayObject
;
const
PIC_SIZE
=
200
;
const
GAP
=
2
;
const
onStageMove
=
(
event
:
FYGE
.
MouseEvent
)
=>
{
//鼠标当前位置
const
currentPoint
=
{
x
:
event
.
stageX
,
y
:
event
.
stageY
};
//鼠标按下点到鼠标当前点的偏移量
let
mouseOffsetX
=
currentPoint
.
x
-
startPoint
.
x
;
let
mouseOffsetY
=
currentPoint
.
y
-
startPoint
.
y
;
currentPic
.
x
=
currPicOriginPos
.
x
+
mouseOffsetX
;
currentPic
.
y
=
currPicOriginPos
.
y
+
mouseOffsetY
;
};
const
onMouseUp_pic
=
()
=>
{
//鼠标抬起后应该移出舞台移动事件,否则会重复添加事件
gameWrapper
.
stage
.
removeEventListener
(
FYGE
.
MouseEvent
.
MOUSE_MOVE
,
onStageMove
,
this
);
const
picCenterX
=
currentPic
.
x
+
PIC_SIZE
/
2
;
const
picCenterY
=
currentPic
.
y
+
PIC_SIZE
/
2
;
const
dropCol
=
Math
.
floor
(
picCenterX
/
PIC_SIZE
);
const
dropRow
=
Math
.
floor
(
picCenterY
/
PIC_SIZE
);
const
dropIndex
=
getIndex
(
dropRow
,
dropCol
,
GAME_SIZE
);
console
.
log
(
"drop index"
,
dropIndex
);
const
dropId
=
gamedata
[
dropIndex
];
const
dropPic
=
getPicDisplayById
(
dropId
);
const
currentPicId
=
getPicId
(
currentPic
);
const
currentPicIndex
=
gamedata
.
indexOf
(
currentPicId
);
console
.
log
(
"currentPicIndex"
,
currentPicIndex
);
console
.
log
(
"dropPic"
,
dropPic
);
if
(
dropPic
?.
x
>=
0
)
{
console
.
log
(
"上一个数据"
,
gamedata
.
map
((
i
)
=>
i
+
1
)
);
swap
(
currentPicIndex
,
dropIndex
,
gamedata
);
console
.
log
(
"交换后的数据"
,
gamedata
.
map
((
i
)
=>
i
+
1
)
);
currentPic
.
x
=
dropPic
.
x
;
currentPic
.
y
=
dropPic
.
y
;
dropPic
.
x
=
currPicOriginPos
.
x
;
dropPic
.
y
=
currPicOriginPos
.
y
;
if
(
equalTo
(
INIT_DATA
,
gamedata
))
{
setTimeout
(()
=>
{
alert
(
"恭喜你拼图成功了!"
);
clearInterval
(
timer
);
timer
=
null
;
stage
.
removeChildren
(
countDownText
);
},
300
);
}
else
{
goneStep
++
;
renderGoneStep
();
}
}
else
{
FYGE
.
Tween
.
get
(
currentPic
).
to
(
{
x
:
currPicOriginPos
.
x
,
y
:
currPicOriginPos
.
y
},
200
);
// setTimeout(() => {
// alert("错误");
// currentPic.x = currPicOriginPos.x;
// currentPic.y = currPicOriginPos.y;
// }, 100);
}
};
const
onMouseDown_picItem
=
(
event
:
FYGE
.
MouseEvent
)
=>
{
// 没有开始游戏不让动
if
(
!
startFlag
)
{
return
;
}
currentPic
=
event
.
target
;
//图片鼠标弹起事件,事件触发一次即移除,否则会重复添加鼠标弹起事件
currentPic
.
once
(
FYGE
.
MouseEvent
.
MOUSE_UP
,
onMouseUp_pic
,
this
);
//添加舞台移动事件,鼠标移动即触发
//FYGE.MouseEvent.MOUSE_MOVE 会在鼠标移动过程中触发
gameWrapper
.
stage
.
addEventListener
(
FYGE
.
MouseEvent
.
MOUSE_MOVE
,
onStageMove
,
this
);
//event事件对象
//event.stageX,event.stageY当前鼠标在舞台的位置
//鼠标按下起始点
startPoint
=
{
x
:
event
.
stageX
,
y
:
event
.
stageY
};
//图片起始位置
currPicOriginPos
=
{
x
:
currentPic
.
x
,
y
:
currentPic
.
y
};
gameWrapper
.
addChild
(
currentPic
);
//把当前图片移动到最上层
};
const
PIC_DISPLAY_LIST
=
INIT_DATA
.
map
((
data
)
=>
FYGE
.
Sprite
.
fromUrl
(
PIC_URLS
[
data
])
);
//图片视图数据(列表)
const
getPicDisplayById
=
(
id
)
=>
PIC_DISPLAY_LIST
[
id
];
//获取视图数据方法
const
getPicId
=
(
picDisplay
)
=>
{
for
(
let
i
=
0
;
i
<
PIC_DISPLAY_LIST
.
length
;
i
++
)
{
const
element
=
PIC_DISPLAY_LIST
[
i
];
if
(
element
==
picDisplay
)
return
i
;
}
return
-
1
;
};
//你会看到用索引的好处
//生成游戏
const
renderGame
=
()
=>
{
gamedata
.
map
((
data
,
index
)
=>
{
const
picItem
=
gameWrapper
.
addChild
(
getPicDisplayById
(
data
));
const
col
=
index
%
GAME_SIZE
;
const
row
=
Math
.
floor
(
index
/
GAME_SIZE
);
picItem
.
x
=
col
*
(
PIC_SIZE
+
GAP
);
picItem
.
y
=
row
*
(
PIC_SIZE
+
GAP
);
//增加鼠标按下事件
picItem
.
addEventListener
(
FYGE
.
MouseEvent
.
MOUSE_DOWN
,
onMouseDown_picItem
,
this
);
return
picItem
;
});
};
renderGame
();
};
src/main.ts
View file @
ffe30319
import
{
add
DragDemo
}
from
"./drag
"
;
import
{
add
Tween
}
from
"./tween
"
;
var
canvas
:
any
=
document
.
getElementById
(
"canvas"
)
canvas
.
width
=
document
.
body
.
clientWidth
*
1
...
...
@@ -22,7 +22,7 @@ canvas.addEventListener('touchend', mouseEvent, false);
stage
.
addEventListener
(
FYGE
.
Event
.
INIT_STAGE
,
onInitStage
,
this
);
function
onInitStage
()
{
add
DragDemo
(
stage
);
add
Tween
(
stage
);
}
(
function
loop
()
{
...
...
src/svga.ts
0 → 100644
View file @
ffe30319
export
const
addSvga
=
(
stage
:
FYGE
.
Stage
)
=>
{
const
SvgaDemo
=
(
videoItem
:
SvgaParser
.
VideoEntity
)
=>
{
const
movie
=
new
FYGE
.
MovieClip
(
vi
)
};
SvgaDemo
(
e
);
};
src/tween.ts
0 → 100644
View file @
ffe30319
export
const
addTween
=
(
stage
:
FYGE
.
Stage
)
=>
{
// 开始游戏按钮
const
addTweenObjBtn
=
()
=>
{
let
shp
=
new
FYGE
.
Shape
();
shp
.
beginFill
(
0x00ff00
);
shp
.
drawRect
(
50
,
0
,
100
,
100
);
shp
.
endFill
();
stage
.
addChild
(
shp
);
const
tw
=
FYGE
.
Tween
.
get
(
shp
,
{
loop
:
true
});
tw
.
to
({
x
:
250
},
500
)
.
call
(()
=>
{
renderText
(
1
);
})
.
wait
(
100
)
.
to
({
y
:
250
},
500
)
.
call
(()
=>
{
renderText
(
2
);
})
.
wait
(
100
)
.
to
({
x
:
50
},
500
)
.
call
(()
=>
{
renderText
(
3
);
})
.
wait
(
100
)
.
to
({
y
:
50
},
500
)
.
call
(()
=>
{
renderText
(
4
);
})
.
wait
(
100
);
};
// addTweenObjBtn();
const
renderText
=
(
index
)
=>
{
console
.
log
(
"index"
,
index
);
};
//
const
addAnimation
=
()
=>
{
let
shp
=
new
FYGE
.
Shape
();
shp
.
beginFill
(
0x00ff00
);
shp
.
drawRect
(
50
,
0
,
200
,
400
);
shp
.
endFill
();
stage
.
addChild
(
shp
);
const
tw
=
FYGE
.
Tween
.
get
(
shp
,
{
loop
:
true
});
// 缓出 减速 FYGE.Ease.quadOut
// tw.set({ y: -200 }).to({ y: 200 }, 1000, FYGE.Ease.quartOut);
// 缓入 加速 FYGE.Ease.quartIn
// tw.set({ y: 200 }).to({ y: shp.stage.stageHeight }, 1000, FYGE.Ease.quartIn);
// 缓入缓出 标准曲线
// shp.rotation = -60;
tw
.
set
({
x
:
200
,
y
:
200
})
.
to
({
rotation
:
40
},
3000
,
FYGE
.
Ease
.
quartInOut
)
.
to
({
rotation
:
-
40
},
3000
,
FYGE
.
Ease
.
quartInOut
);
};
addAnimation
();
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment