animation

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package animation are the components for running and sprite.Sprite animations

Index

Constants

This section is empty.

Variables

View Source
var Get = gets{

	Animation: func(e *entity.Entity) Animation {
		return e.Get(TYPE.Animation).(Animation)
	},

	State: func(e *entity.Entity) State {
		return e.Get(TYPE.State).(State)
	},

	Sequence: func(e *entity.Entity) Sequence {
		return e.Get(TYPE.Sequence).(Sequence)
	},
}

Get animation component

TYPE hold the reflect.Type for our animation components

Functions

This section is empty.

Types

type Animation

type Animation struct {
	Sequences map[string]Sequence // Sequences is the different AnimationSequence for this Animation
	Current   string              // Current is the animation that be like to run
	Speed     float32             // Speed is a multiplier of th speed of the current animation
	FlipX     bool                // FlipX indicates if the Animation is flipped in the X-Assis
	FlipY     bool                // FlipY indicates if the Animation is flipped in the Y-Assis
}

Animation allow to easily switch animations

type Sequence

type Sequence struct {
	Sheet    string  // Sheet is the sprite sheet where the animation sprites are
	Base     string  // Base is the base name for each frame. ex : Idle_%d.png
	Rotation float32 // Rotation for this AnimationSequence
	Scale    float32 // Scale for this AnimationSequence
	Frames   int32   // Frames are the number of frame in this animation
	Delay    float32 // Delay number of seconds to wait in each frame
}

Sequence represent a set of frames that will be render with a delay

type State

type State struct {
	Current string  // Current is the animation that is running
	Speed   float32 // Speed is the current animation speed
	Time    float32 // Time is the time in this frame
	Frame   int32   // Frame is the current frame number
}

State allow to easily switch animations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL