feat: added a few new parameters to add gapping for reading from images.
This commit is contained in:
parent
8fcb1c2dc5
commit
7b9025b062
2 changed files with 4 additions and 3 deletions
|
@ -36,7 +36,7 @@ type AnimationId int
|
||||||
type AnimationSet map[AnimationId] Animation
|
type AnimationSet map[AnimationId] Animation
|
||||||
func AnimationSetFromImage(
|
func AnimationSetFromImage(
|
||||||
img *Image,
|
img *Image,
|
||||||
w, h int,
|
w, h, gx, gy int,
|
||||||
defines ...AnimationDefine,
|
defines ...AnimationDefine,
|
||||||
) (AnimationSet, error) {
|
) (AnimationSet, error) {
|
||||||
set := AnimationSet{}
|
set := AnimationSet{}
|
||||||
|
@ -50,8 +50,8 @@ func AnimationSetFromImage(
|
||||||
idx := define.Indexes[i]
|
idx := define.Indexes[i]
|
||||||
animation[i] = ebiten.NewImageFromImage(img.SubImage(
|
animation[i] = ebiten.NewImageFromImage(img.SubImage(
|
||||||
ImageRect{
|
ImageRect{
|
||||||
Min: ImagePoint{idx.X*fw, idx.Y*fh},
|
Min: ImagePoint{idx.X*fw+gx, idx.Y*fh+gy},
|
||||||
Max: ImagePoint{(idx.X+1)*fw, (idx.Y+1)*fh},
|
Max: ImagePoint{(idx.X+1)*fw-gx, (idx.Y+1)*fh-gy},
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ func main() {
|
||||||
playerAnimations, _ = gg.AnimationSetFromImage(
|
playerAnimations, _ = gg.AnimationSetFromImage(
|
||||||
playerImg,
|
playerImg,
|
||||||
8, 3,
|
8, 3,
|
||||||
|
10, 1,
|
||||||
gg.AD(Stand).DefRow(0, 0, 1, 2, 3, 4),
|
gg.AD(Stand).DefRow(0, 0, 1, 2, 3, 4),
|
||||||
gg.AD(Walk).DefRow(1, 0, 1, 2, 3, 4, 5, 6, 7),
|
gg.AD(Walk).DefRow(1, 0, 1, 2, 3, 4, 5, 6, 7),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue