【发布时间】:2016-08-02 21:21:26
【问题描述】:
我已经制作了一个 processing.js 网页,我用它来放置一个平台游戏,所以我已经计划好了代码。现在我只需要把它放在网页上。现在我可以将背景设置为红色,但是当我输入代码时,我意识到它没有绘制任何图像。我查了一下,processing.js 使用的图像方法与我正在做的非常不同。还是不行。
这是我在 HelloWeb.pde 文件中的 processing.js 代码:
preload =
"file:///E:/Extra%20Curricular/STEM%20Videogame/Art/BlackKingIdle.png";
//注意E盘是我的U盘。不知道会不会有效果?
//AI Codes
int wolfX = 310;
int wolfY = 200;
int wolfHealth = 50;
//Health
int kingHealth = 100;
int dragon = 500;
//LV design
int floorHeight = 300;
int lvlNum = 1;
//movement (x)
int maxSpeed = 6.25;
int xForce = 0;
int kingXPos = 947.5;
//movement (y)
int kingYPos = floorHeight + 50;
int yForce = -15;
int jumping = false;
void setup() {
size(1895, 800);
background(255, 0, 0);
}
void draw() {
if (lvlNum != 0) {
PImage kingIdle = loadImage("file:///E:/Extra%20Curricular/STEM%20Videogame/Art/BlackKingIdle.png")
}
};
还有 HTML:
<!DOCTYPE html>
<html>
<head>
<title>Hello Web - Processing.js Test</title>
<script src="processing.min.js"></script>
</head>
<body>
<h1>Processing.js Test</h1>
<p>This is my first Processing.js web-based sketch:</p>
<canvas data-processing-sources="HelloWeb.pde" width="1895" height="800" style="border:4px solid"></canvas>
</body>
</html>
【问题讨论】:
标签: image processing.js