Skip to content

Commit 9cc394e

Browse files
committed
feat: add type sprite on hilo engine
1 parent c6d7b1b commit 9cc394e

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

src/scripts/hilo.js

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,27 +73,34 @@ class HiloEngine extends Engine {
7373
3 * Math.random() * rnd[Math.floor(Math.random() * 2)],
7474
3 * Math.random() * rnd[Math.floor(Math.random() * 2)],
7575
];
76-
const circle = new Hilo.Graphics({
77-
width: size * 2,
78-
height: size * 2,
79-
x: x,
80-
y: y,
81-
});
82-
if (this.type === 'stroke')
83-
circle
84-
.lineStyle(1, '#ffffff')
85-
.drawCircle(1, 1, size - 1)
86-
.closePath()
87-
.endFill()
88-
.addTo(this.graphicScene);
89-
else if (this.type === 'fill')
90-
circle
91-
.beginFill('#fff')
92-
.lineStyle(1, '#000000')
93-
.drawCircle(1, 1, size - 1)
94-
.closePath()
95-
.endFill()
96-
.addTo(this.graphicScene);
76+
let circle;
77+
if (this.type === 'sprite') {
78+
circle = new Hilo.Bitmap({
79+
image: 'sprite.png',
80+
}).addTo(this.graphicScene);
81+
} else {
82+
circle = new Hilo.Graphics({
83+
width: size * 2,
84+
height: size * 2,
85+
x: x,
86+
y: y,
87+
});
88+
if (this.type === 'stroke')
89+
circle
90+
.lineStyle(1, '#ffffff')
91+
.drawCircle(1, 1, size - 1)
92+
.closePath()
93+
.endFill()
94+
.addTo(this.graphicScene);
95+
else if (this.type === 'fill')
96+
circle
97+
.beginFill('#fff')
98+
.lineStyle(1, '#000000')
99+
.drawCircle(1, 1, size - 1)
100+
.closePath()
101+
.endFill()
102+
.addTo(this.graphicScene);
103+
}
97104
particles[i] = { x, y, size: size, dx, dy, el: circle };
98105
}
99106
this.particles = particles;

0 commit comments

Comments
 (0)