Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnimationSet ¶
type AnimationSet struct {
// contains filtered or unexported fields
}
AnimationSet represents a set of image for animation
func NewAnimationSet ¶
func NewAnimationSet() *AnimationSet
NewAnimationSet returns an instance of AnimationSet
func (*AnimationSet) AddTexture ¶
func (animation *AnimationSet) AddTexture(texture *Texture)
AddTexture adds a specified texture to AnimationSet
func (*AnimationSet) SetInterval ¶
func (animation *AnimationSet) SetInterval(interval int64)
SetInterval sets interval of animation
type Audioer ¶
type Audioer interface { Play(resource asset.File, loop bool, doneCallback func(err error)) error Stop() error }
Audioer is an interface for treating audio
type Collider ¶
type Collider interface {
GetXYWH() (x, y, w, h float32)
}
Collider represents an interface of collidables
type CollisionListener ¶
type CollisionListener interface {
OnCollision(c1, c2 Collider)
}
CollisionListener represents a interface of listener of collision
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database is a container of Databaser
type Databaser ¶
type Databaser interface { Open(dirpath string) error Close() Put(key string, value interface{}) Get(key string) interface{} }
Databaser represents interface of database
type Driver ¶
type Driver interface { // Initialize is called to initialize scene. Initialize(sim Simraer) // Drive is called about 60 times per 1 sec. // It is the chance to update sprite information like // position, appear/disappear, and change scene. Drive() }
Driver represents a scene driver.
type PubSub ¶
type PubSub struct {
// contains filtered or unexported fields
}
PubSub is an object to control publish and subscribe
func (*PubSub) Publish ¶
func (p *PubSub) Publish(i interface{})
Publish publishes specified object to all subscriber
func (*PubSub) Subscribe ¶
func (p *PubSub) Subscribe(id string, s Subscriber) error
Subscribe adds a subscriber to publisher
func (*PubSub) Unsubscribe ¶
Unsubscribe remove a subscriber
type Publisher ¶
type Publisher interface { Publish(i interface{}) Subscribe(id string, s Subscriber) error Unsubscribe(id string) }
Publisher is publisher interface for pubsub system
type Simraer ¶
type Simraer interface { // Start needs to call to enable all function belong to simra package. Start(driver Driver) // SetScene sets a driver as a scene. // If a driver is already set, it is replaced with new one. SetScene(driver Driver) // NewSprite returns an instance of Spriter NewSprite() Spriter // AddSprite adds a sprite to current scene with empty texture. AddSprite(s Spriter) // RemoveSprite removes specified sprite from current scene. // Removed sprite will be disappeared. RemoveSprite(s Spriter) // SetZIndex sets specified zindex to specified Spriter. // All Spriter has 0 as zindex as default. // Spriters will be draw as the order of zindex in descending. // Spriter that has lesser number of zindex will be draw latter. // // If specified sprite is not found (removed or not added yet), // this function returns non-nil error. SetZIndex(s Spriter, z int) error // GetZIndex returns specified Spriter's zindex // // If specified sprite is not found (removed or not added yet), // this function returns non-nil error. GetZIndex(s Spriter) (int, error) // SetDesiredScreenSize configures virtual screen size. // This function must be called at least once before calling Start. SetDesiredScreenSize(w, h float32) // AddTouchListener registers a listener for notifying touch event. // Event is notified when "screen" is touched. AddTouchListener(listener TouchListener) // RemoveTouchListener unregisters a listener for notifying touch event. RemoveTouchListener(listener TouchListener) // AddCollisionListener add a callback function that is called on // collision is detected between c1 and c2. AddCollisionListener(c1, c2 Collider, listener CollisionListener) // RemoveAllCollisionListener removes all registered listeners RemoveAllCollisionListener() // NewImageTexture returns a texture instance of image NewImageTexture(assetName string, rect image.Rectangle) *Texture // NewImageTexture returns a texture instance of text NewTextTexture(text string, fontsize float64, fontcolor color.RGBA, rect image.Rectangle) *Texture // SetOnStopCallback sets a callback function that will be called on application goes invisible SetOnStopCallback(f func()) }
Simraer represents an interface of simra instance
type Spriter ¶
type Spriter interface { // ReplaceTexture replaces sprite's texture with specified image resource. ReplaceTexture(texture *Texture) // AddTouchListener registers a listener for touch event. // Touch event will be notified when "sprite" is touched. AddTouchListener(listener peer.TouchListener) // RemoveAllTouchListener removes all listeners already registered. RemoveAllTouchListener() // AddAnimationSet adds a specified AnimationSet to sprite AddAnimationSet(animationName string, set *AnimationSet) // StartAnimation starts animation by specified animation name StartAnimation(animationName string, shouldLoop bool, animationEndCallback func()) // StopAnimation stops animation StopAnimation() // SetPosition sets sprite's position SetPosition(x, y float32) // SetPositionX sets sprite's position X SetPositionX(x float32) // SetPositionY sets sprite's position Y SetPositionY(y float32) // SetScale sets sprite's size SetScale(w, h float32) // SetScaleW sets sprite's size W SetScaleW(w float32) // SetScaleH sets sprite's size H SetScaleH(h float32) // GetPosition gets sprites position GetPosition() Position // GetScale gets sprites size GetScale() Scale // SetRotate sets sprite's rotation SetRotate(r float32) // getRotate gets sprite's rotation GetRotate() float32 }
Spriter represents an interface of Sprite
type Subscriber ¶
type Subscriber interface {
OnEvent(i interface{})
}
Subscriber is subscriber interface for pubsub system
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
Texture represents a texture.
type TouchListener ¶
type TouchListener peer.TouchListener
TouchListener is interface to receive touch event