Commit af58fed4 authored by 谌继荃's avatar 谌继荃

篮球,盲盒

parent 2bf68b74
......@@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>拼图</title>
<title>游戏</title>
<script src="http://yun.duiba.com.cn/db_games/libs0924/fyge2018.minSpine.js" crossorigin="anonymous"></script>
<style>
html,
......
const MIN_LEVEL = 1;
const MAX_LEVEL = 3;
export const LEVEL_UPDATE = "LEVEL_UPDATE";
export default class SwapLevelButton extends FYGE.Sprite {
currentLevel: number;
constructor() {
super();
this.currentLevel = MIN_LEVEL;
this.initButton();
}
onclick = () => {
this.currentLevel++;
if (this.currentLevel > MAX_LEVEL) this.currentLevel = MIN_LEVEL;
};
initButton() {
this.texture = FYGE.Texture.fromUrl(
"//yun.duiba.com.cn/aurora/assets/7866a9522c988482ce9b808795017e844aadce4d.png"
);
this.addEventListener(FYGE.MouseEvent.CLICK, this.onclick);
}
}
const ACTION_DATA = {
STANDBY:
"//yun.duiba.com.cn/aurora/assets/619e5784aae7641247c34ed8433b653f2ac67e69.svga",
JUMP: "//yun.duiba.com.cn/aurora/assets/dd2fa41dc91642a08c79a1ee38f80e1f8c319075.svga",
I_LOVE_YOU:
"//yun.duiba.com.cn/aurora/assets/9ef3b1ab48bb010d2604cfda02bd07c0e07e5780.svga",
};
import { createMovieClip } from "./util";
export const changeDress = async (gameContainer: FYGE.Container) => {
console.log("资源加载中,请稍后....");
const actions = await Promise.all(
Object.keys(ACTION_DATA).map((actionId) =>
createMovieClip(ACTION_DATA[actionId])
)
);
console.log("资源加载完成,可以显示了");
const INITIAL_STATE = 0;
let current = INITIAL_STATE;
function onActionClick(event: FYGE.MouseEvent) {
event.target.visible = false;
current++;
if (current == Object.keys(ACTION_DATA).length) current = INITIAL_STATE;
actions[current].visible = true;
actions[current].gotoAndPlay(1);
}
//这里可以添加点击事件了
actions.forEach((action, index) => {
gameContainer.addChild(action);
action.addEventListener(FYGE.MouseEvent.CLICK, onActionClick);
if (index !== current)
//默认先显示standby
action.visible = false;
});
};
const ACTION_DATA = {
STANDBY:
"//yun.duiba.com.cn/aurora/assets/619e5784aae7641247c34ed8433b653f2ac67e69.svga",
JUMP: "//yun.duiba.com.cn/aurora/assets/dd2fa41dc91642a08c79a1ee38f80e1f8c319075.svga",
I_LOVE_YOU:
"//yun.duiba.com.cn/aurora/assets/9ef3b1ab48bb010d2604cfda02bd07c0e07e5780.svga",
};
import { createMovieClip, getSvgaImage } from "./util";
import SwapLevelButton from "./SwapLevelButton";
export const changeImg = async (gameContainer: FYGE.Container) => {
console.log("资源加载中,请稍后....");
const actions = await createMovieClip(ACTION_DATA["STANDBY"]);
console.log("资源加载完成,可以显示了");
const EQUIP_MAX = ["psd_1456", "psd_1454"]; //所有的装备
const EQUIP = {
"1": [], //1级没有装备
"2": [EQUIP_MAX[1]], //二级只有帽子
"3": EQUIP_MAX, //三级有帽子和狗
};
// 如果你想同时拥有狗的情况下,也拥有星星,可以这样:
const star = FYGE.Sprite.fromUrl(
"//yun.duiba.com.cn/aurora/assets/0d5d6380ff56211e96f0c6c700584b77111d922c.png"
);
star.position.set(100, 0);
getSvgaImage(actions, "psd_1456").addChild(star);
gameContainer.addChild(actions);
function swapLevel() {
const level = swapLevelButton.currentLevel;
console.log(`切换到等级${level}`);
const equips: string[] = EQUIP[level];
EQUIP_MAX.forEach((key) => {
getSvgaImage(actions, key).visible = equips.indexOf(key) != -1;
});
}
const swapLevelButton = new SwapLevelButton();
swapLevelButton.addEventListener(FYGE.MouseEvent.CLICK, swapLevel);
gameContainer.addChild(swapLevelButton);
swapLevel();
};
export const PIC_URLS = [
"//yun.duiba.com.cn/aurora/assets/cd16134f2544202ed5676adbd5114286aec44347.png",
"//yun.duiba.com.cn/aurora/assets/c55dcd277542a6c3e983278ae5835d89848b9bd9.png",
"//yun.duiba.com.cn/aurora/assets/b42c49baaf8754139d2e940fe97ba1cb289b11fa.png",
"//yun.duiba.com.cn/aurora/assets/4a4b850995da348ccd5fb520d5b9ef5e0fb8349f.png",
"//yun.duiba.com.cn/aurora/assets/5b3e3b52f406df1543e2eeca1ce11719a28c6401.png",
"//yun.duiba.com.cn/aurora/assets/cae0529d1ff2eaa323dc0615d12a1f05e3a67c06.png",
"//yun.duiba.com.cn/aurora/assets/5b91853f9d87de73e319d42ea9df139ddd89d537.png",
"//yun.duiba.com.cn/aurora/assets/a2893c5a0d03ca3252160de1584584e18abe2a4a.png",
"//yun.duiba.com.cn/aurora/assets/c36b0851f61a812e6d745bc205c0551b6590d11d.png",
"//yun.duiba.com.cn/aurora/assets/cd16134f2544202ed5676adbd5114286aec44347.png",
"//yun.duiba.com.cn/aurora/assets/c55dcd277542a6c3e983278ae5835d89848b9bd9.png",
"//yun.duiba.com.cn/aurora/assets/b42c49baaf8754139d2e940fe97ba1cb289b11fa.png",
];
export const GAME_SIZE = 3;
export const GAME_SIZE2 = 3;
\ No newline at end of file
import { addBall } from "./ballMove";
// import { addBall } from "./ball"; // 篮球 左中右方向
// import { addBall } from "./ballMove"; // 篮网移动
import { addBlindBox } from "./blindBox"; // 盲盒
var canvas: any = document.getElementById("canvas");
canvas.width = document.body.clientWidth * 1;
canvas.height = document.body.clientHeight * 1;
......@@ -21,7 +24,8 @@ canvas.addEventListener("touchend", mouseEvent, false);
stage.addEventListener(FYGE.Event.INIT_STAGE, onInitStage, this);
function onInitStage() {
addBall(stage);
// addBall(stage); // 篮球
addBlindBox(stage); // 盲盒
}
(function loop() {
......
import { playOnce, playOnce2, createMovieClip } from "./util";
export const addSvga = (stage: FYGE.Stage) => {
const svga =
"//yun.duiba.com.cn/aurora/assets/5f08147edbef6bbab218b1a9efa1ea9090ccc836.svga";
// const SvgaDemo = (videoItem: SvgaParser.VideoEntity) => {
// const movie = new FYGE.MovieClip(videoItem);
// stage.addChild(movie);
// };
// loadSvga(svga, SvgaDemo);
const addSvgaDemo2 = async (stage: FYGE.Stage) => {
const url = await createMovieClip(svga);
const movieclip = stage.addChild(url);
await playOnce2(movieclip);
movieclip.parent && movieclip.parent.removeChild(movieclip);
};
addSvgaDemo2(stage);
};
import { playOnce, createMovieClip, waitClick, addFrameScript } from "./util";
export const addSvga2 = (stage: FYGE.Stage) => {
const svga =
"//yun.duiba.com.cn/aurora/assets/bf45970fcee87ee5eac58040806003ba924664eb.svga";
const addSvgaDemo6 = async (stage: FYGE.Stage) => {
const INTERRUPT = 28; //断点1
const INTERRUPT2 = 80; //断点2
console.log("资源加载中,请稍后....");
const url = await createMovieClip(svga);
const movieclip = stage.addChild(url);
console.log("费劲巴拉终于加载完了,播吧....");
/**
* 优先级最高,会覆盖
* @param beginFrame 默认1
* @param endFrame 默认 this.totalFrames
* @param loops 默认1 小于等于0为无线循环,
* @param callback 动画循环次数播放结束时回调,无限循环时不会有回调
*/
// startAniRange(beginFrame?: number, endFrame?: number, loops?: number, callback?: Function): void;
movieclip.startAniRange(1, INTERRUPT);
await waitClick(movieclip);
movieclip.startAniRange(INTERRUPT, INTERRUPT2);
await waitClick(movieclip);
movieclip.startAniRange(INTERRUPT2, movieclip.totalFrames);
addFrameScript(movieclip, movieclip.totalFrames, () => {
console.log("结束了");
});
};
addSvgaDemo6(stage);
};
import { createMovieClip } from "./util";
export const changespeedDemo = async (gameContainer: FYGE.Container) => {
const jump = await createMovieClip(
"//yun.duiba.com.cn/aurora/assets/dd2fa41dc91642a08c79a1ee38f80e1f8c319075.svga"
);
gameContainer.addChild(jump);
jump.gotoAndStop(1);
let currentFrame = 1;
const MULTI = 4; // 设置倍数
function onEnterFrame() {
currentFrame = currentFrame + MULTI;
jump.gotoAndStop(currentFrame);
if (currentFrame > jump.totalFrames) currentFrame = 1;
}
jump.addEventListener(FYGE.Event.ENTER_FRAME, onEnterFrame);
};
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 renderB = () => {
/// 代码段 B
var obj = { x: 0 };
var funcChange = function (): void {
console.log(this.x);
};
FYGE.Tween.get(obj, { onChange: funcChange, onChangeObj: obj }).to(
{ x: 600 },
1000,
FYGE.Ease.backInOut
);
};
// renderB();
//
const addAnimation = () => {
let shp = new FYGE.Shape();
shp.beginFill(0x00ff00);
shp.drawRect(50, 0, 200, 400);
shp.endFill();
stage.addChild(shp);
var funcChange = function (): void {
console.log(this.y);
};
const tw = FYGE.Tween.get(shp, { onChange: funcChange, onChangeObj: shp });
// 缓出 减速 FYGE.Ease.quadOut
tw.set({ y: -200 }).to({ y: 200 }, 1000, FYGE.Ease.quadOut);
// 缓入 加速 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();
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment