首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ReferenceError: /sketch.js:6:3中未定义loadAnimation

ReferenceError: /sketch.js:6:3中未定义loadAnimation
EN

Stack Overflow用户
提问于 2021-07-21 03:29:19
回答 1查看 38关注 0票数 0
代码语言:javascript
复制
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没有在/sketch.js:6:3中定义

EN

回答 1

Stack Overflow用户

发布于 2021-07-21 04:19:16

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

代码语言:javascript
复制
<script src="https://molleindustria.github.io/p5.play/lib/p5.play.js"></script>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68460387

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档