@echo off
setlocal enabledelayedexpansion
for %%a in (*.png) do (
set "name=%%~na"
set "newname=!name:~-3!"
ren "%%a" "!newname!.png"
)
export const init_config = [
{
index: 0,
name: "normal",
frames: 60,
texture: [],
object: {
loop: true,
},
}
];
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html,
body {
width: 100vw;
height: 100vh;
overflow: hidden;
}
.taro-pet {
width: 100vw;
height: 100vh;
transform: scaleX(-1);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TaroPet</title>
<link rel="stylesheet" href="./public/css/index.css" />
</head>
<body>
<div id="taro-pet" class="taro-pet">
<canvas id="taro-canvas"></canvas>
</div>
<script src="./public/js/pixi.min.js"></script>
<script src="./_renderer/renderer.js" type="module"></script>
</body>
</html>
// 当前使用的模型
let current_module = "kkr";
// 初始配置和动作配置
let init_config = null;
// 初始动画
let anim_normal = null;
// 动画的舞台
let app = null;
// 动画的canvas
let anim_canvas = null;
// 获取窗口的大小
const bower_width = window.innerWidth;
const bower_height = window.innerHeight;
// 页面加载完成执行
window.addEventListener("load", async (event) => {
// 获取配置
const module = await import(`../modules/${current_module}/${current_module}.js`);
init_config = module.init_config;
// 赋值canvas
anim_canvas = document.getElementById("taro-canvas");
// 动画舞台配置
app = new PIXI.Application({
view: anim_canvas,
width: bower_width,
height: bower_height,
backgroundAlpha: 0,
resolution: 1,
});
// 添加给div-taropet元素
document.getElementById("taro-pet").appendChild(app.view);
// 先把初始的动画加载完成
anim_normal = await create_anim_func(init_config[0]);
anim_normal.play();
app.stage.addChild(anim_normal);
});
// 创建动画的方法
const create_anim_func = async (obj) => {
// 存放文件前缀, 文件格式(png,jpg)
const file_prefix = "./modules";
const file_format = ".png";
const { name, frames, object } = obj;
const texture_array = [];
// 通过帧数循环获取贴图
for (let i = 0; i < frames; i++) {
const num = `000${i}`.slice(-3);
// texture_name ./modules/kkr/normal/001.png
const texture_name = `${file_prefix}/${current_module}/${name}/${num}${file_format}`;
const texture = await PIXI.Texture.from(texture_name);
texture_array.push(texture);
}
// 生成动画,配置动画属性
const anim = new PIXI.AnimatedSprite(texture_array);
anim.name = name;
anim.animationSpeed = 0.5;
anim.loop = object.loop;
return anim;
};
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html,
body {
width: 100vw;
height: 100vh;
overflow: hidden;
}
.taro-pet {
width: 100vw;
height: 100vh;
transform: scaleX(-1);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TaroPet</title>
<link rel="stylesheet" href="./public/css/index.css" />
</head>
<body>
<div id="taro-pet" class="taro-pet">
<canvas id="taro-canvas"></canvas>
</div>
<script src="./public/js/pixi.min.js"></script>
<script src="./_renderer/renderer.js" type="module"></script>
</body>
</html>
// 当前使用的模型
let current_module = "kkr";
// 初始配置和动作配置
let init_config = null;
// 初始动画
let anim_normal = null;
// 动画的舞台
let app = null;
// 动画的canvas
let anim_canvas = null;
// 获取窗口的大小
const bower_width = window.innerWidth;
const bower_height = window.innerHeight;
// 页面加载完成执行
window.addEventListener("load", async (event) => {
// 获取配置
const module = await import(`../modules/${current_module}/${current_module}.js`);
init_config = module.init_config;
// 赋值canvas
anim_canvas = document.getElementById("taro-canvas");
// 动画舞台配置
app = new PIXI.Application({
view: anim_canvas,
width: bower_width,
height: bower_height,
backgroundAlpha: 0,
resolution: 1,
});
// 添加给div-taropet元素
document.getElementById("taro-pet").appendChild(app.view);
// 先把初始的动画加载完成
anim_normal = await create_anim_func(init_config[0]);
anim_normal.play();
app.stage.addChild(anim_normal);
});
// 创建动画的方法
const create_anim_func = async (obj) => {
// 存放文件前缀, 文件格式(png,jpg)
const file_prefix = "./modules";
const file_format = ".png";
const { name, frames, object } = obj;
const texture_array = [];
// 通过帧数循环获取贴图
for (let i = 0; i < frames; i++) {
const num = `000${i}`.slice(-3);
// texture_name ./modules/kkr/normal/001.png
const texture_name = `${file_prefix}/${current_module}/${name}/${num}${file_format}`;
const texture = await PIXI.Texture.from(texture_name);
texture_array.push(texture);
}
// 生成动画,配置动画属性
const anim = new PIXI.AnimatedSprite(texture_array);
anim.name = name;
anim.animationSpeed = 0.5;
anim.loop = object.loop;
return anim;
};
此页面不支持夜间模式!
已进入夜间模式!
已进入普通模式!
搜索框不允许为空
签到成功!经验+5!芋圆币+2!
签到失败!今日已签到!
需要登录社区账号才可以进入!