赞 | 158 |
VIP | 0 |
好人卡 | 0 |
积分 | 263 |
经验 | 0 |
最后登录 | 2025-7-6 |
在线时间 | 5300 小时 |
Lv5.捕梦者
- 梦石
- 0
- 星屑
- 26308
- 在线时间
- 5300 小时
- 注册时间
- 2016-3-8
- 帖子
- 1657
|
本帖最后由 alexncf125 于 2025-6-13 11:47 编辑
要是把图片放在img/picturs/food的话,倒是可以用以下代码来随机播放一个图片,但放在img/food那就不知道了
const fs = require('fs');
const path = require('path');
const dir = path.join('./img/pictures/food');
const files = fs.readdirSync(dir).map((file) => file.split(/\./)[0]);
const file = files[Math.floor(Math.random() * files.length)];
// $gameScreen.showPicture(图片编号, `food/${file}`, 原点, x坐标, y坐标, x放大率, y放大率, 不透明度, 合成方式);
$gameScreen.showPicture(1, `food/${file}`, 1, Graphics.boxWidth / 2, Graphics.boxHeight / 2, 100, 100, 255, 0); |
|