Skip to content

Commit 66084a0

Browse files
committed
feat: add type sprite on two.js engine
1 parent 1627a8a commit 66084a0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/scripts/two.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,16 @@ class TwoEngine extends Engine {
3636
3 * Math.random() * rnd[Math.floor(Math.random() * 2)],
3737
3 * Math.random() * rnd[Math.floor(Math.random() * 2)],
3838
];
39-
const circle = this.two.makeCircle(0, 0, size);
39+
let circle;
40+
if (this.type === 'sprite') {
41+
circle = new Two.Sprite('/sprite.png', x, y, 1, 1);
42+
this.two.add(circle);
43+
} else {
44+
circle = this.two.makeCircle(0, 0, size);
45+
if (this.type === 'stroke') circle.noFill().stroke = '#ffffff';
46+
else if (this.type === 'fill') circle.stroke = '#000000';
47+
}
4048
circle.position.set(0, 0);
41-
if (this.type === 'stroke') circle.noFill().stroke = '#ffffff';
42-
else if (this.type === 'fill') circle.stroke = '#000000';
4349
particles[i] = { x, y, size: size, dx, dy, el: circle };
4450
}
4551
this.particles = particles;

0 commit comments

Comments
 (0)