正如P5.Play引用所指定的,我尝试使用开始帧和结束帧在预加载中加载动画,它只加载第一帧和最后一帧,而不是预先填充它们之间的所有帧。这对于有15帧左右的动画来说不是问题,但我有一些关于80+的。
function preload() {
chargeExplosion = loadAnimation('assets/chargeExplosion/frame0000.png', 'assets/chargeExplosion/frame0081.png');
}
function setup() {
createCanvas(500, 500)
}
function draw() {
explosion1 = createSprite(width / 2, height / 2, 40, 40);
explosion1.addAnimation('boom', chargeExplosion);
}这段代码过于简单,因为我有几百行以上的代码,但我已经确保绝对没有任何干扰。当我单独预加载每个单独的帧时,动画运行得很好,我真的不想在剩下的帧中也这样做。
发布于 2021-10-13 05:32:36
p5.play中的
drawSprites()
let chargeExplosion;
let explosion1;
function preload() {
chargeExplosion = loadAnimation('https://www.paulwheeler.us/files/AnimFrame00.png', 'https://www.paulwheeler.us/files/AnimFrame02.png');
}
function setup() {
createCanvas(windowWidth, windowHeight);
explosion1 = createSprite(width / 2, height / 2, 40, 40);
chargeExplosion.frameDelay = 30;
explosion1.addAnimation('boom', chargeExplosion);
}
function draw() {
background(220);
drawSprites();
}<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>
<script src="https://www.paulwheeler.us/files/p5.play.js?r=0"></script>
https://stackoverflow.com/questions/69535420
复制相似问题