mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-11-01 20:22:37 +08:00
@@ -59,7 +59,7 @@ type sprite struct {
|
||||
img *ebiten.Image
|
||||
scale float64
|
||||
angle float64
|
||||
alpha float64
|
||||
alpha float32
|
||||
}
|
||||
|
||||
func (s *sprite) update() {
|
||||
@@ -94,8 +94,8 @@ func (s *sprite) draw(screen *ebiten.Image) {
|
||||
op.GeoM.Translate(x, y)
|
||||
op.GeoM.Translate(ox, oy)
|
||||
|
||||
rate := float64(s.count) / float64(s.maxCount)
|
||||
alpha := 0.0
|
||||
rate := float32(s.count) / float32(s.maxCount)
|
||||
var alpha float32
|
||||
if rate < 0.2 {
|
||||
alpha = rate / 0.2
|
||||
} else if rate > 0.8 {
|
||||
@@ -104,7 +104,7 @@ func (s *sprite) draw(screen *ebiten.Image) {
|
||||
alpha = 1
|
||||
}
|
||||
alpha *= s.alpha
|
||||
op.ColorM.Scale(1, 1, 1, alpha)
|
||||
op.ColorScale.ScaleAlpha(alpha)
|
||||
|
||||
screen.DrawImage(s.img, op)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user