- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在java中编写一个20个板堆栈,使用按键功能堆叠一个新板,并使用鼠标单击功能使各个板一一消失到0。我不明白为什么我的函数不会'他们不会按照我的命令去做工作,请帮忙。
// Declare global (shared) variables here
float plate1X = 50;
float plate1Y = 200;
int plateCount = 20;
// Do not write any statements here (must be inside methods)
// Add statements to run once when program starts here. For example:
void setup() {
size(400,400);
plate1X = 200;
plate1Y = 50;
background(255);
plate1X = width/2;
plate1Y = height-25;
} // end of setup method
void draw()
{
// Declare local variables here (new each time through)
// Add statements to run each time screen is updated here
ellipse(plate1X, plate1Y, 200,50);
stroke(0);
fill(50,100,40);
}
// Screen will be repainted automatically at the end of draw method
// end of draw method
// Add other methods here
void keyPressed() {
plate1Y = -25;
while( plate1Y < height)
ellipse(plate1X, plate1Y, 200,50);
plate1Y = plate1Y - 10;
}
void mousePressed() {
while( plate1Y <= -205)
ellipse(plate1X, plate1Y, 200,50);
plate1Y = plate1Y + 10;
}
最佳答案
每次调用 draw()
方法时,您都需要绘制每个板,这种情况通常每秒发生 60 次。您可以在两个数组 plateX[]
和 plateY[]
中保持每个板的协调,并用 numPlates
跟踪有多少个板。您可以在 keyPressed()
和 mousePressed()
方法中向数组添加或减去条目,但不要在其中进行任何实际绘制。
// Declare global (shared) variables here
float plate1X = 50;
float plate1Y = 200;
int plateCount = 20;
int numPlates = 1;
float plateX[] = new float[plateCount];
float plateY[] = new float[plateCount];
// Do not write any statements here (must be inside methods)
// Add statements to run once when program starts here. For example:
void setup() {
size(400,400);
background(255);
plate1X = width/2;
plate1Y = height-25;
plateX[0]=plate1X;
plateY[0]=plate1Y;
} // end of setup method
void draw()
{
// Declare local variables here (new each time through)
// Add statements to run each time screen is updated here
for(int i=0;i<numPlates;++i)
ellipse(plateX[i], plateY[i], 200,50);
stroke(0);
fill(50,100,40);
}
// Screen will be repainted automatically at the end of draw method
// end of draw method
// Add other methods here
void keyPressed() {
plate1Y -= 25;
if( plate1Y > 0) {
plateX[numPlates]=plate1X;
plateY[numPlates]=plate1Y;
++numPlates;
}
}
void mousePressed() {
--numPlates;
plate1Y += 25;
}
关于java - 如何使用 if 或 while 语句将 20 个 "plate"外观对象(椭圆形)堆叠到 20 个?我的功能无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22614076/
我是 PHP 的新手,试图了解如何使用 PHP 使用简单的模板系统,我喜欢“Plates”,主要是因为它声称是模板系统,而不是模板语言,但文档有点困惑.作为这个代码“ Controller ”离开
我正在使用html5 boilerplate开发一个基于jquery移动的实验性应用程序。作为 html 等的基础。 到目前为止我所做的基本上是: 下载并解压 html5 样板文件,然后在浏览器中查看
我想在服务器端构建我的 html 代码。 为此,我使用 Plates,它是一个模板 javascript 库。 我试图让这段代码正常工作,但它只是没有修改原始的 html 模板代码... var Pl
我刚开始看 plates ,因为很多人都在谈论它。 有一些带有少量 html 片段的板示例,但不是真正成熟的模板文件。所以我想知道如何将布局特别是分成一个 layout.html 文件,并将内容分发到
所以,我刚开始使用 flatironjs 和“plates”。我试图弄清楚如何拥有一个主布局模板,然后是一个将内容加载到主布局模板中的部分模板,类似于 expressjs 的做法...... 对于 e
我是JSON的新手。我正在做一个车牌检测的项目。我有一个表格的数据集:。总共有240个数据块。我想用上面的数据集做两件事。首先,我需要从每个块下载所有的图像,其次,需要获得“Points”列的值到一个
目前我有两个项目。用于管理信息的“Backend”MVC 项目(工作完全正常)。我现在正在构建一个“Frontend”MVC 项目。我正在使用 ASP NET ZEROS 提供的演示。 我已经创建了应
我可以轻松地对存储在叶子中的项目进行遍历: data Tree a = Br (Tree a) (Tree a) | Lf a deriving (Data) instance Plated
使用最新版本的 Bound 和 Control.Lens.Plated,以下 transform 调用会导致程序无限循环并愉快地咀嚼远离我的内存。有趣的是终止程序会导致打印正确的结果,尽管我不知道为什
在将一些项目从 Objective-C 迁移到 Swift 时,我发现自己用更多样板代码替换了 @property/@synthesize 语法。 例如,对于我正在实现的每个 @property,我目
我生成了一组 n 元素数组,其中交替包含 1 和 -1,后跟零,所有元素都以 1 开头。 例如,对于 n=5,数组为:10000,1-1000,1-1100,1-11-10,1-11-11, 我需要在
我正在拼命尝试将 GOES-16 netCDF 文件中的一些对地静止数据投影到不同的投影。我可以获取背景 map 来重新投影,但似乎无法获取要跟踪的数据。 我对此还不是很精通,但到目前为止,这是我所掌
我尝试这样的代码: static float shift = 0.0; double amplitude = 1000000 * pow(10, 1 / 400.0); for (int i = 0;
来自express.js,想给flatiron尝试一个小项目。但是,有一些小问题使我无法真正取得进展。 var flatiron = require('flatiron') , session =
工作人员,这个问题适用于相信 Debian linux,更准确地说是 Raspbian 的任何人,这是一个在 Raspberry Pi 板上运行的版本: 树莓派的所有用户都应该知道:操作系统安装在 S
我正在尝试在java中编写一个20个板堆栈,使用按键功能堆叠一个新板,并使用鼠标单击功能使各个板一一消失到0。我不明白为什么我的函数不会'他们不会按照我的命令去做工作,请帮忙。 // Declare
我是一名优秀的程序员,十分优秀!