diff --git a/animation.go b/animation.go index 5ba39cc..0be2332 100644 --- a/animation.go +++ b/animation.go @@ -36,7 +36,7 @@ type AnimationId int type AnimationSet map[AnimationId] Animation func AnimationSetFromImage( img *Image, - w, h int, + w, h, gx, gy int, defines ...AnimationDefine, ) (AnimationSet, error) { set := AnimationSet{} @@ -50,8 +50,8 @@ func AnimationSetFromImage( idx := define.Indexes[i] animation[i] = ebiten.NewImageFromImage(img.SubImage( ImageRect{ - Min: ImagePoint{idx.X*fw, idx.Y*fh}, - Max: ImagePoint{(idx.X+1)*fw, (idx.Y+1)*fh}, + Min: ImagePoint{idx.X*fw+gx, idx.Y*fh+gy}, + Max: ImagePoint{(idx.X+1)*fw-gx, (idx.Y+1)*fh-gy}, }, )) } diff --git a/cmd/test/main.go b/cmd/test/main.go index 938928f..ad215f2 100644 --- a/cmd/test/main.go +++ b/cmd/test/main.go @@ -55,6 +55,7 @@ func main() { playerAnimations, _ = gg.AnimationSetFromImage( playerImg, 8, 3, + 10, 1, gg.AD(Stand).DefRow(0, 0, 1, 2, 3, 4), gg.AD(Walk).DefRow(1, 0, 1, 2, 3, 4, 5, 6, 7), )