【问题标题】:ReferenceError: loadAnimation is not defined at /sketch.js:6:3ReferenceError: loadAnimation 未定义在 /sketch.js:6:3
【发布时间】:2021-09-28 06:59:42
【问题描述】:
var boat,groundImage; //variables declared

function preload(){
 
  boat = loadAnimation("b2.png"); //loading animation
  groundImage = loadImage("b1.jpg");
  
  
}

function setup() {
  createCanvas(600, 400); //draw canvas
}

function draw() 
{
 background(180);
image(groundImage,0,0);
animation(boat,0,0); //locate animation
}

这里是在 p5.js 编辑器中使用动画的简单代码。但我收到一个错误:ReferenceError: loadAnimation is not defined at /sketch.js:6:3

【问题讨论】:

    标签: javascript web animation editor p5.js


    【解决方案1】:

    loadAnimation() 函数不是p5.js 的一部分。它由p5.play add-on 添加。我只能假设您忘记在 index.html 中添加对 p5.play 的引用,因为您没有包含 minimal, reproducible example

    <script src="https://molleindustria.github.io/p5.play/lib/p5.play.js"></script>
    

    【讨论】:

      猜你喜欢
      • 2014-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-04
      • 2021-07-17
      • 1970-01-01
      • 2012-08-24
      • 2016-12-09
      相关资源
      最近更新 更多