3 Коміти 72c0d66777 ... f494bbcb69

Автор SHA1 Опис Дата
  lzj500 f494bbcb69 打包 1 рік тому
  lzj500 5692f58e53 修改完毕 1 рік тому
  lzj500 e165dcc458 完成动画 1 рік тому

Різницю між файлами не показано, бо вона завелика
+ 1 - 1
game_test1/dist/build/h5/assets/index-a83a5860.css


Різницю між файлами не показано, бо вона завелика
+ 1 - 0
game_test1/dist/build/h5/assets/Hilo.70feeeab.js


Різницю між файлами не показано, бо вона завелика
+ 0 - 6
game_test1/dist/build/h5/assets/Page.4def1186.js


Різницю між файлами не показано, бо вона завелика
+ 6 - 0
game_test1/dist/build/h5/assets/Page.692802d8.js


Різницю між файлами не показано, бо вона завелика
+ 6 - 0
game_test1/dist/build/h5/assets/index-22fb332c.js


+ 1 - 0
game_test1/dist/build/h5/assets/index-af1de908.css

@@ -0,0 +1 @@
+.page .titlebar[data-v-d7fb647b]{position:absolute;width:100%;left:0;top:0}.page .btn[data-v-d7fb647b]{border:solid .03125rem #999;background-color:#f5f5f}

Різницю між файлами не показано, бо вона завелика
+ 1 - 0
game_test1/dist/build/h5/assets/index-f4d6aab9.css


Різницю між файлами не показано, бо вона завелика
+ 0 - 6
game_test1/dist/build/h5/assets/index-f75b97fd.js


+ 1 - 0
game_test1/dist/build/h5/assets/index1-054747a2.css

@@ -0,0 +1 @@
+.page .titlebar[data-v-a7562da9]{position:absolute;width:100%;left:0;top:0}.page .btn[data-v-a7562da9]{border:solid .03125rem #999;background-color:#f5f5f5}.page .game_container[data-v-a7562da9]{margin:0 auto}

Різницю між файлами не показано, бо вона завелика
+ 1 - 0
game_test1/dist/build/h5/assets/pages-hilo-index.21ca0b71.js


Різницю між файлами не показано, бо вона завелика
+ 0 - 1
game_test1/dist/build/h5/assets/pages-hilo-index.9d1ea0ee.js


Різницю між файлами не показано, бо вона завелика
+ 3 - 0
game_test1/dist/build/h5/assets/pages-hilo-index1.92c0089d.js


+ 0 - 1
game_test1/dist/build/h5/assets/pages-index-index.2a34e99c.js

@@ -1 +0,0 @@
-import{g as s,h as a,o,a as e,w as t,k as l,m as n,v as i,i as r}from"./index-f75b97fd.js";import{P as c}from"./Page.4def1186.js";const d=s({__name:"index",setup:s=>(a("Hello"),(s,a)=>{const d=r;return o(),e(d,{class:"content"},{default:t((()=>[l(d,{class:"p20 fs40 text_color_link",onClick:a[0]||(a[0]=s=>i(c).goto("/pages/hilo/index"))},{default:t((()=>[n("演示1")])),_:1})])),_:1})})});export{d as default};

Різницю між файлами не показано, бо вона завелика
+ 1 - 0
game_test1/dist/build/h5/assets/pages-index-index.73767965.js


Різницю між файлами не показано, бо вона завелика
+ 0 - 1
game_test1/dist/build/h5/assets/uni.3fd42165.css


Різницю між файлами не показано, бо вона завелика
+ 1 - 0
game_test1/dist/build/h5/assets/uni.904901ef.css


+ 2 - 2
game_test1/dist/build/h5/index.html

@@ -2,7 +2,7 @@
 <html>
 
 <head>
-  <link rel="stylesheet" href="./assets/uni.3fd42165.css">
+  <link rel="stylesheet" href="./assets/uni.904901ef.css">
 
   <meta charset="UTF-8" />
   <script>
@@ -15,7 +15,7 @@
   <title></title>
   <!--preload-links-->
   <!--app-context-->
-  <script type="module" crossorigin src="./assets/index-f75b97fd.js"></script>
+  <script type="module" crossorigin src="./assets/index-22fb332c.js"></script>
   <link rel="stylesheet" href="./assets/index-5e524323.css">
 </head>
 

+ 70 - 0
game_test1/src/libs/game1/Asset.ts

@@ -0,0 +1,70 @@
+import Hilo from "../hilo/Hilo";
+const Asset = {
+	Mixes: Hilo.EventMixin,
+	fire: Hilo.EventMixin.fire,
+	on: Hilo.EventMixin.on,
+	off: Hilo.EventMixin.off,
+	queue: null as any,
+	bg: null,
+	man: null as any,
+	bom: null as any,
+	ground: null,
+	ready: null,
+	over: null,
+	numberGlyphs: null,
+	birdAtlas: null,
+	holdback: null,
+
+	load: function () {
+		let host = "https://ssl.ycxxkj.com/demo_list/game_test1/dist/build/h5";
+		var resources = [
+			{ id: "bg", src: host + "/static/images/map.jpg" },
+			{ id: "man", src: host + "/static/images/man.png" },
+			{ id: "bom", src: host + "/static/images/bom.png" }
+		];
+		console.log("#debug#🚀 ~ file: Asset.ts:24 ~ resources:", resources);
+
+		this.queue = new Hilo.LoadQueue();
+		this.queue.add(resources);
+		this.queue.on("complete", this.onComplete.bind(this));
+		this.queue.start();
+	},
+
+	onComplete: function (e: any) {
+		console.log("#debug#🚀 ~ file: Asset.ts:33 ~  Asset onComplete: Asset");
+		this.bg = this.queue.get("bg").content;
+
+		this.man = new Hilo.TextureAtlas({
+			image: this.queue.get("man").content,
+			width: 204,
+			height: 375,
+
+			frames: {
+				frameWidth: 204,
+				frameHeight: 375,
+				numFrames: 13
+			},
+			sprites: {
+				man: { from: 0, to: 12 }
+			}
+		});
+
+		this.bom = new Hilo.TextureAtlas({
+			image: this.queue.get("bom").content,
+			width: 137,
+			height: 135.31,
+
+			frames: {
+				frameWidth: 137,
+				frameHeight: 135.31,
+				numFrames: 16
+			},
+			sprites: {
+				bom: { from: 0, to: 12 }
+			}
+		});
+		this.queue.off("complete");
+		this.fire("complete");
+	}
+};
+export default Asset;

+ 250 - 0
game_test1/src/libs/game1/Game.ts

@@ -0,0 +1,250 @@
+import Hilo from "../hilo/Hilo";
+import { Yc, YcUniapp } from "@ycxxkj/uniapp";
+console.log("#debug#🚀 ~ file: game.ts:2 ~ Hilo:", Hilo);
+import Asset from "./Asset";
+console.log("#debug#🚀 ~ file: game.ts:4 ~ Asset:", Asset);
+let stage: any;
+let stepLong = 200;
+let stepTime = 1000;
+let mapWidth = 1381;
+let mapHeight = 1043;
+let mapMin = 0;
+let map: any;
+let camera: any;
+let bmpHeight = 0; //地图高度
+let bmpWidth = 0; //地图宽度
+let stepArray = [
+	{ x: 1400, y: 1000, bomX: 1250, bomY: 1100, position: 1, bomShow: true, workLong: 1000, step: 0 },
+	{ x: 1300, y: 1050, bomX: 1150, bomY: 1100, position: 1, bomShow: true, workLong: 1000, step: 1 },
+	{ x: 1180, y: 1060, bomX: 1050, bomY: 1100, position: 1, bomShow: true, workLong: 1000, step: 2 },
+	{ x: 1100, y: 1060, bomX: 920, bomY: 1100, position: 1, bomShow: true, workLong: 1000, step: 3 },
+	{ x: 980, y: 1030, bomX: 720, bomY: 980, position: 1, bomShow: true, workLong: 1000, step: 4 },
+	{ x: 720, y: 900, bomX: 600, bomY: 930, position: 1, bomShow: true, workLong: 3000, step: 5 },
+	{ x: 620, y: 850, bomX: 500, bomY: 900, position: 1, bomShow: true, workLong: 1000, step: 6 },
+	{ x: 520, y: 800, bomX: 420, bomY: 1100, position: 1, bomShow: true, workLong: 1000, step: 7 },
+	{ x: 450, y: 1050, bomX: 220, bomY: 1060, position: 1, bomShow: true, workLong: 2000, step: 8 },
+	{ x: 220, y: 980, bomX: 230, bomY: 720, position: 1, bomShow: true, workLong: 4000, step: 9 },
+	{ x: 340, y: 650, bomX: 250, bomY: 640, position: -1, bomShow: true, workLong: 3000, step: 10 },
+	{ x: 370, y: 580, bomX: 260, bomY: 540, position: -1, bomShow: true, workLong: 1000, step: 11 },
+	{ x: 390, y: 480, bomX: 320, bomY: 390, position: -1, bomShow: true, workLong: 1000, step: 12 },
+	{ x: 430, y: 320, bomX: 460, bomY: 280, position: -1, bomShow: true, workLong: 3000, step: 13 },
+	{ x: 560, y: 200, bomX: 460, bomY: 180, position: -1, bomShow: true, workLong: 2000, step: 14 },
+	{ x: 560, y: 100, bomX: 730, bomY: 80, position: -1, bomShow: true, workLong: 1000, step: 15 },
+	{ x: 860, y: 30, bomX: 830, bomY: 80, position: -1, bomShow: true, workLong: 3000, step: 16 }
+];
+class Game {
+	private stage: any;
+	private asset: any;
+	private bg: any;
+	private width: number;
+	private height: number;
+	private scale: number = 0.5;
+	private man: any;
+	private bom: any;
+	public playing = false;
+
+	constructor(container: any, width = 375, height = 667) {
+		let mapScale = 1; //this.scale;
+		this.width = width;
+		this.height = height;
+		bmpHeight = mapHeight * 2; //地图高度
+		bmpWidth = (mapWidth / mapHeight) * bmpHeight; //地图宽度
+
+		this.stage = stage = new Hilo.Stage({
+			renderType: "canvas",
+			container: container,
+			width: width,
+			height: height,
+			scaleX: this.scale,
+			scaleY: this.scale
+		});
+
+		//设置deadzone区域
+		var dw = 100,
+			dh = 100;
+		var deadzone = [dw, dh, 0, 0];
+
+		//新建摄像机,设置边界,deadzone
+		camera = new Hilo.Camera({
+			width: width,
+			height: height,
+			bounds: [0, 0, mapWidth - width + 100, 0],
+			deadzone: deadzone
+		});
+
+		//创建地图
+		map = new Hilo.Container().addTo(stage);
+
+		Asset.on("complete", () => {
+			Asset.off("complete");
+			this.init();
+		});
+		Asset.load();
+
+		var ticker = new Hilo.Ticker(60);
+		ticker.addTick(stage);
+		ticker.addTick(Hilo.Tween); //需要把Tween加到ticker里才能使用
+		ticker.addTick(camera);
+		//map跟随摄像机滚动
+		ticker.addTick({
+			tick: function () {
+				map.x = -camera.scroll.x;
+				map.y = -camera.scroll.y;
+			}
+		});
+		ticker.start();
+	}
+	init() {
+		let bgImg: any = Asset.bg;
+		let scale = (this.height * 2) / bmpHeight;
+		mapMin = this.width * scale * 2 - bmpWidth;
+		console.log("#debug#🚀 ~ file: Game.ts:68 ~ Game ~ init ~ bmpHeight:", bmpWidth, bmpHeight, scale, mapMin);
+
+		console.log("#debug#🚀 ~ file: Game.ts:72 ~ Game ~ init ~ this.height:", this.height);
+
+		let bg = new Hilo.Bitmap({
+			id: "bg",
+			image: bgImg,
+			rect: [0, 0, mapWidth, mapHeight],
+			x: 0,
+			y: 0,
+			scaleX: scale,
+			scaleY: scale
+		}).addTo(map);
+		//计算边界
+		// map.x = mapMin;
+		// map.x = -500;
+		// map.y = 300;
+		//this.map.y = -400;
+
+		//显示deadzone区域
+		// stage.addChild(
+		// 	new Hilo.View({
+		// 		x: 100,
+		// 		y: 500,
+		// 		width: camera.deadzone[2],
+		// 		height: camera.deadzone[3],
+		// 		background: "rgba(255, 0, 0, .3)"
+		// 	})
+		// );
+		this.initMan();
+	}
+	initMan() {
+		let index = 0; // stepArray.length - 1;
+		this.bom = new Hilo.Sprite({
+			frames: Asset.bom.getSprite("bom"),
+			x: stepArray[index].bomX,
+			y: stepArray[index].bomY,
+			scaleX: 1,
+			scaleY: 1,
+			interval: 8,
+			timeBased: false,
+			loop: true,
+			paused: true, //!stepArray[0].bomShow,
+			onUpdate: function () {}
+		}).addTo(map);
+		console.log("#debug#🚀 ~ file: game.ts:90 ~ Game ~ initMan ~ bom:", this.bom);
+		console.log("#debug#🚀 ~ file: game.ts:65 ~ Game ~ initMan ~ Asset.getman:", Asset.man), Asset.man.getSprite("man");
+		this.man = new Hilo.Sprite({
+			frames: Asset.man.getSprite("man"),
+			x: stepArray[index].x,
+			y: stepArray[index].y,
+			scaleX: 0.5 * stepArray[index].position,
+			scaleY: 0.5,
+			interval: 5,
+			timeBased: false,
+			loop: true,
+			paused: true,
+			onUpdate: function () {
+				/* this.x += this.speed;
+				console.log("#debug#🚀 ~ file: Game.ts:125 ~ Game ~ initMan ~ this.speed:", this.speed);
+				console.log("#debug#🚀 ~ file: Game.ts:125 ~ Game ~ initMan ~ this.x :", this.x);
+				if (this.x > mapWidth - 100 || this.x < 100) {
+					this.speed *= -1;
+					this.scaleX *= -1;
+				} */
+				/* this.y += this.speed;
+				if (this.y > mapHeight - 100 || this.y < 100) {
+					this.speed *= -1;
+					this.scaleX *= -1;
+				} */
+			}
+		}).addTo(map);
+		this.man.speed = 2;
+
+		//摄像机跟谁鱼
+		camera.follow(this.man);
+		console.log("#debug#🚀 ~ file: game.ts:78 ~ Game ~ initMan ~ this.man:", this.man);
+
+		this.animotion();
+	}
+
+	/**
+	 * 动画
+	 */
+	animotion() {
+		this.playing = true;
+		console.log("#debug#🚀 ~ file: Game.ts:181 ~ Game ~ 开始动画 ");
+		YcUniapp.toast("开始播放动画");
+		let man = this.man;
+		this.man.x = stepArray[0].x;
+		this.man.y = stepArray[0].y;
+		this.man.scaleX = 0.5 * stepArray[0].position;
+		this.goStep(1);
+		console.log("#debug#🚀 ~ file: Game.ts:181 ~ Game ~ 结束动画 ");
+	}
+	async goStep(step: number) {
+		let that = this;
+		let man = this.man;
+		let bom = this.bom;
+		if (stepArray[step].bomShow) {
+			bom.alpha = 1;
+			bom.paused = !stepArray[step].bomShow;
+			bom.x = stepArray[step - 1].bomX;
+			bom.y = stepArray[step - 1].bomY;
+			await Yc.delay(2500);
+			bom.paused = true;
+			bom.alpha = 0;
+		}
+
+		man.paused = false;
+		man.scaleX = 0.5 * stepArray[step].position;
+		Hilo.Tween.to(
+			man,
+			{ x: stepArray[step].x, y: stepArray[step].y },
+			{
+				duration: stepArray[step].workLong,
+				onComplete: function () {
+					man.paused = true;
+					console.log("complete 完成第", step, "步,数组步数", stepArray[step].step, man);
+
+					if (step == stepArray.length - 1) {
+						that.playing = false;
+						YcUniapp.toast("播放动画完毕");
+					}
+
+					if (step < stepArray.length - 1) {
+						console.log("#debug#🚀 ~ file: Game.ts:209 ~ Game ~ goStep ~ stepArray.length:", stepArray.length);
+						that.goStep(step + 1);
+					} else {
+						this.playing = false;
+					}
+				}
+			}
+		);
+	}
+
+	startBom() {
+		console.log("#debug#🚀 ~ file: game.ts:102 ~ Game ~ startBom ~ startBom:");
+		this.bom.x = parseInt((Math.random() * (700 + 1 - 50)).toString()) + 50;
+		this.bom.y = parseInt((Math.random() * (500 + 1 - 50)).toString()) + 50;
+		this.bom.paused = false;
+		this.bom.alpha = 1;
+	}
+	stopBom() {
+		console.log("#debug#🚀 ~ file: game.ts:107 ~ Game ~ stopBom ~ stopBom:");
+		this.bom.paused = true;
+		this.bom.alpha = 0;
+	}
+}
+export default Game;

+ 5 - 2
game_test1/src/pages.json

@@ -1,10 +1,13 @@
 {
 	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
 		{
-			"path": "pages/hilo/index"
+			"path": "pages/index/index"
 		},
 		{
-			"path": "pages/index/index"
+			"path": "pages/hilo/index1"
+		},
+		{
+			"path": "pages/hilo/index"
 		}
 	],
 	"globalStyle": {

+ 108 - 0
game_test1/src/pages/hilo/index1.vue

@@ -0,0 +1,108 @@
+<template>
+	<view class="page">
+		<view class="p20 tc">红军长征动画</view>
+		<view class="canvas_box pos_r">
+			<!-- <view class="tc p20 titlebar">canvas演示</view> -->
+			<!-- <canvas id="canvasId" class="canvas" /> -->
+			<div id="game-container" class="bg_ff game_container"></div>
+		</view>
+		<view class="p20 tc">
+			<u-button type="primary" @click="restart" class="w200">重新播放</u-button>
+		</view>
+		<view class="dis_none">
+			<view class="tl mt20 text_color_tips pl20">为方便演示动画,提供功能按钮看效果</view>
+			<view class="dis_flex_align_between_center p20">
+				<view class="left dis_flex">
+					<u-button type="primary" @click="startBom" class="w100">开炮</u-button>
+
+					<u-button type="primary" @click="stopBom" class="ml30 w100">停炮</u-button>
+				</view>
+				<view class="w300 tc">
+					<u-button class="w100" type="primary" @click="goUp">向上</u-button>
+					<view class="dis_flex_align_between_center mt20 mb20">
+						<u-button type="primary" class="w100" @click="goLeft">向左</u-button>
+						<u-button type="primary" class="w100" @click="goRight">向右</u-button>
+					</view>
+
+					<u-button type="primary" class="w100" @click="goDown">向下</u-button>
+				</view>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script setup lang="ts">
+import { onMounted, ref } from "vue";
+import { onLoad } from "@dcloudio/uni-app";
+import Page from "../../libs/pages/Page";
+import Game from "@/libs/game1/Game";
+const title = ref("Hello");
+let stage;
+let game: any;
+const init = () => {
+	let gameContainer: any = document.getElementById("game-container");
+	let sysinfo = uni.getSystemInfoSync();
+	console.log("#debug#🚀 ~ file: index.vue:22 ~ init ~ sysinfo:", sysinfo);
+	// alert(JSON.stringify(sysinfo));
+	let devicePixelRatio = sysinfo.pixelRatio;
+	console.log("#debug#🚀 ~ file: index.vue:22 ~ init ~ devicePixelRatio:", devicePixelRatio);
+
+	let width = 375 * 2; //uni.upx2px(sysinfo.screenWidth) * 4; //sysinfo.screenWidth;
+	let height = 667 * 2; // uni.upx2px(sysinfo.windowHeight) * 4; // (566 / 750) * width;
+	gameContainer.style.height = height / 2 + "px"; // sysinfo.safeArea?.height + "px";
+	gameContainer.style.width = width / 2 + "px"; //sysinfo.safeArea?.right + "px";
+	game = new Game(gameContainer, width, height);
+	// game.init();
+};
+
+const restart = () => {
+	if (game.playing) {
+		Page.YcUniapp.toast("请动画结束后再播放");
+		return;
+	}
+	game.animotion();
+};
+const goLeft = () => {
+	game.goLeft();
+};
+const startBom = () => {
+	game.startBom();
+};
+const goUp = () => {
+	game.goUp();
+};
+const goRight = () => {
+	game.goRight();
+};
+const goDown = () => {
+	game.goDown();
+};
+const stopBom = () => {
+	game.stopBom();
+};
+onLoad(async () => {
+	uni.setNavigationBarTitle({
+		title: "动画演示"
+	});
+	await Page.Yc.delay(100);
+	init();
+});
+</script>
+
+<style lang="scss" scoped>
+.page {
+	.titlebar {
+		position: absolute;
+		width: 100%;
+		left: 0;
+		top: 0;
+	}
+	.btn {
+		border: solid 1rpx #999;
+		background-color: #f5f5f5;
+	}
+	.game_container {
+		margin: 0 auto;
+	}
+}
+</style>

+ 20 - 7
game_test1/src/pages/index/index.vue

@@ -1,14 +1,27 @@
 <template>
-  <view class="content">
-    <view class="p20 fs40 text_color_link" @click="Page.goto('/pages/hilo/index')">演示1</view>
-  </view>
+	<view class="content">
+		<view class="p40 tc fs40">红军长征动画DEMO</view>
+		<view class="pl40 pr40 pt15 pb15 fs40 bds_t bds_b dis_flex_align_between_center center" @click="Page.goto('/pages/hilo/index')">
+			<view>
+				<view class="fs32 text_color_link">版本1</view>
+				<view class="fs24 mt10 text_color_tips">手动控制</view>
+			</view>
+			<u-icon name="arrow-right" color="#999999"></u-icon>
+		</view>
+		<view class="pl40 pr40 pt15 pb15 fs40 bds_t bds_b dis_flex_align_between_center center" @click="Page.goto('/pages/hilo/index1')">
+			<view>
+				<view class="fs32 text_color_link">版本2</view>
+				<view class="fs24 mt10 text_color_tips">预设动画,地图放大,镜头随主人公移动</view>
+			</view>
+			<u-icon name="arrow-right" color="#999999"></u-icon>
+		</view>
+	</view>
 </template>
 
 <script setup lang="ts">
-import { ref } from 'vue'
+import { ref } from "vue";
 import Page from "@/libs/pages/Page";
-const title = ref('Hello')
+const title = ref("Hello");
 </script>
 
-<style lang="scss" scoped>
-</style>
+<style lang="scss" scoped></style>