mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-06-29 18:45:23 +00:00
Add RenderFromOrigin method to Animation (#317)
* Configuration cleanup * Cleanup * Add RenderFromOrigin option
This commit is contained in:
parent
6f2c212417
commit
418c798c2c
|
@ -43,6 +43,7 @@ type Animation struct {
|
||||||
|
|
||||||
compositeMode d2render.CompositeMode
|
compositeMode d2render.CompositeMode
|
||||||
colorMod color.Color
|
colorMod color.Color
|
||||||
|
originAtBottom bool
|
||||||
|
|
||||||
playMode playMode
|
playMode playMode
|
||||||
playLength float64
|
playLength float64
|
||||||
|
@ -118,6 +119,7 @@ func createAnimationFromDC6(dc6 *d2dc6.DC6File) (*Animation, error) {
|
||||||
animation := &Animation{
|
animation := &Animation{
|
||||||
playLength: 1.0,
|
playLength: 1.0,
|
||||||
playLoop: true,
|
playLoop: true,
|
||||||
|
originAtBottom: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
for frameIndex, dc6Frame := range dc6.Frames {
|
for frameIndex, dc6Frame := range dc6.Frames {
|
||||||
|
@ -218,6 +220,17 @@ func (a *Animation) Render(target d2render.Surface) error {
|
||||||
return target.Render(frame.image)
|
return target.Render(frame.image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Animation) RenderFromOrigin(target d2render.Surface) error {
|
||||||
|
if a.originAtBottom {
|
||||||
|
direction := a.directions[a.directionIndex]
|
||||||
|
frame := direction.frames[a.frameIndex]
|
||||||
|
target.PushTranslation(0, -frame.height)
|
||||||
|
defer target.Pop()
|
||||||
|
}
|
||||||
|
|
||||||
|
return a.Render(target)
|
||||||
|
}
|
||||||
|
|
||||||
func (a *Animation) GetFrameSize(frameIndex int) (int, int, error) {
|
func (a *Animation) GetFrameSize(frameIndex int) (int, int, error) {
|
||||||
direction := a.directions[a.directionIndex]
|
direction := a.directions[a.directionIndex]
|
||||||
if frameIndex >= len(direction.frames) {
|
if frameIndex >= len(direction.frames) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user