mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Examples updated accordingly
This commit is contained in:
+5
-4
@@ -23,7 +23,8 @@ void setup() {
|
||||
sprite = loadImage("sprite.png");
|
||||
|
||||
for (int n = 0; n < npartTotal; n++) {
|
||||
PShape part = createShape(QUAD);
|
||||
PShape part = createShape();
|
||||
part.beginShape(QUAD);
|
||||
part.noStroke();
|
||||
part.texture(sprite);
|
||||
part.normal(0, 0, 1);
|
||||
@@ -31,7 +32,7 @@ void setup() {
|
||||
part.vertex(+partSize/2, -partSize/2, sprite.width, 0);
|
||||
part.vertex(+partSize/2, +partSize/2, sprite.width, sprite.height);
|
||||
part.vertex(-partSize/2, +partSize/2, 0, sprite.height);
|
||||
part.end();
|
||||
part.endShape();
|
||||
particles.addChild(part);
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ void draw () {
|
||||
|
||||
if (0 <= lifetimes[n]) {
|
||||
float opacity = 1.0 - float(lifetimes[n]) / partLifetime;
|
||||
part.tint(255, opacity * 255);
|
||||
part.setTint(color(255, opacity * 255));
|
||||
|
||||
if (lifetimes[n] == 0) {
|
||||
// Re-spawn dead particle
|
||||
@@ -73,7 +74,7 @@ void draw () {
|
||||
velocities[n].y += gravity;
|
||||
}
|
||||
} else {
|
||||
part.tint(0, 0);
|
||||
part.setTint(color(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user