Documentation ¶
Overview ¶
Package shake provides methods for rapidly shifting graphical components' positions
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultShaker is the global default shaker, used when shake.Screen or shake.Shake are called. DefaultShaker = &Shaker{ Random: false, Magnitude: floatgeom.Point2{3.0, 3.0}, Delay: 30 * time.Millisecond, ResetPosition: true, } )
Functions ¶
func Screen ¶
Screen shakes the screen that the context controls for the given duration. It uses the settings in DefaultShaker to determine the quality of the shake.
func Shake ¶
func Shake(sp ShiftPoser, dur time.Duration)
Shake shakes a ShiftPoser for the given duration. It uses the settings in DefaultShaker to determine the quality of the shake.
Types ¶
type Shaker ¶
type Shaker struct { Magnitude floatgeom.Point2 Delay time.Duration Random bool // ResetPosition determines whether the shaken entity will be reset back to its original position // after shaking is complete. True by default. ResetPosition bool }
A Shaker knows how to shake something by a (or up to a) given magnitude. If Random is true, the Shaker will shake up to the (negative or positive) magnitude of each the X and Y axes. Otherwise, it will oscillate between negative magnitude and positive magnitude.
func (*Shaker) Shake ¶
func (sk *Shaker) Shake(sp ShiftPoser, dur time.Duration)
Shake shakes a ShiftPoser for the given duration.
func (*Shaker) ShakeContext ¶
ShakeContext shakes a ShiftPoser for the given duration or until the context is done, whichever comes first.
type ShiftPoser ¶
type ShiftPoser interface {
ShiftPos(x, y float64)
}
A ShiftPoser can have its position shifted by an x,y pair