javascript - 我试图找到一种方法,所以当它低于某个 y 时,文本将变为红色(p5.js)
问题描述
// Background
var backgroundt = createSprite(200,200,200,200);
backgroundt.setAnimation("pine_trees_1");
// Bee
var bee1 = createSprite(200,200,200,200);
bee1.setAnimation("bee_1");
bee1.x = 200;
bee1.y = 200;
// Draw Function
function draw() {
bee1.x = bee1.x - 2;
bee1.y = bee1.y + 4;
drawSprites();
fill("yellow");
textFont("Times New Roman");
textSize(50);
text("Honey!", 138,196);
}
// Drawing the sprites
drawSprites();
var y2 = 398;
while(bee1.y < y2) {
fill("red");
textFont("Times New Roman");
textSize(50);
text("Honey!", 138,196);
}
我试图获得蜜蜂的 Y 值,但我不知道它是否可能,如果不是还有其他方法吗?我在想这是否行不通,也许是为什么要让文本在屏幕上传送?这是 p5.js 顺便说一句。
解决方案
推荐阅读
- python - 每个组的 pandas 返回比第一个更大的行
- angular - 当用户登录我的侧栏菜单时没有显示
- base64 - 在 XQuery 中将 base64 解码为字符串并将字符串编码为 base64
- node.js - 如何通过在表单中插入 url 链接将图像插入到 MongoDb 中
- r - 将值分配给向量中的位置时,如何同时传递值的名称?
- windows - 使用 c++ 在 Windows 7 及更高版本中打印相机驱动程序的驱动程序版本
- python - 将对象从 Python 流式传输到 PowerShell?
- testing - 授权码格式错误,soapui 中的授权无效
- r - 复制与前一行相反的数据帧行
- sql - 一行中最小值和最大值的 SQL 命令