Documentation
¶
Index ¶
- type GLContext
- type GLPeer
- func (glpeer *GLPeer) AppendNode(zn *ZNode)
- func (glpeer *GLPeer) Finalize()
- func (glpeer *GLPeer) Initialize(glc *GLContext)
- func (glpeer *GLPeer) LoadTexture(assetName string, rect image.Rectangle) sprite.SubTex
- func (glpeer *GLPeer) MakeTextureByText(text string, fontsize float64, fontcolor color.RGBA, rect image.Rectangle) sprite.SubTex
- func (glpeer *GLPeer) NewNode(fn arrangerFunc) *ZNode
- func (glpeer *GLPeer) NewTexture(s sprite.SubTex) *Texture
- func (glpeer *GLPeer) ReleaseTexture(t *Texture)
- func (glpeer *GLPeer) RemoveNode(n *ZNode)
- func (glpeer *GLPeer) Reset()
- func (glpeer *GLPeer) SetSubTex(zn *ZNode, subTex *sprite.SubTex)
- func (glpeer *GLPeer) Update(sc SpriteContainerer)
- func (glpeer *GLPeer) ZIndexDirty()
- type GLer
- type Gomo
- type Gomoer
- type ScreenSizer
- type Sprite
- type SpriteContainer
- func (sc *SpriteContainer) AddSprite(s *Sprite, subTex *sprite.SubTex, arrangeCallback func()) error
- func (sc *SpriteContainer) GetSpriteNodePairs() *sync.Map
- func (sc *SpriteContainer) GetZIndex(s *Sprite) (int, error)
- func (sc *SpriteContainer) Initialize(gl GLer)
- func (sc *SpriteContainer) OnTouchBegin(x, y float32)
- func (sc *SpriteContainer) OnTouchEnd(x, y float32)
- func (sc *SpriteContainer) OnTouchMove(x, y float32)
- func (sc *SpriteContainer) RemoveSprite(remove *Sprite)
- func (sc *SpriteContainer) RemoveSprites()
- func (sc *SpriteContainer) ReplaceTexture(sprite *Sprite, texture *Texture)
- func (sc *SpriteContainer) SetZIndex(s *Sprite, z int) error
- type SpriteContainerer
- type Spriter
- type Texture
- type TouchListener
- type TouchPeer
- func (tp *TouchPeer) AddTouchListener(listener TouchListener)
- func (tp *TouchPeer) OnTouchBegin(pxx, pxy float32)
- func (tp *TouchPeer) OnTouchEnd(pxx, pxy float32)
- func (tp *TouchPeer) OnTouchMove(pxx, pxy float32)
- func (tp *TouchPeer) RemoveAllTouchListeners()
- func (tp *TouchPeer) RemoveTouchListener(listener TouchListener)
- type Toucher
- type ZNode
- type ZNodes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GLContext ¶
type GLContext struct {
// contains filtered or unexported fields
}
GLContext is a wrapper of gl.Context
type GLPeer ¶
type GLPeer struct {
// contains filtered or unexported fields
}
GLPeer represents gl context. Singleton.
func (*GLPeer) AppendNode ¶
AppendNode adds specified node as a child
func (*GLPeer) Finalize ¶
func (glpeer *GLPeer) Finalize()
Finalize finalizes GLPeer. This is called at termination of application.
func (*GLPeer) Initialize ¶
Initialize initializes GLPeer. This function must be called in advance of using GLPeer
func (*GLPeer) LoadTexture ¶
LoadTexture return texture that is loaded by the information of arguments. Loaded texture can assign using AddSprite function.
func (*GLPeer) MakeTextureByText ¶
func (glpeer *GLPeer) MakeTextureByText(text string, fontsize float64, fontcolor color.RGBA, rect image.Rectangle) sprite.SubTex
MakeTextureByText create and return texture by specified text Loaded texture can assign using AddSprite function. TODO: font parameterize
func (*GLPeer) NewTexture ¶
NewTexture returns a new Texture instance
func (*GLPeer) ReleaseTexture ¶
ReleaseTexture releases specified texture
func (*GLPeer) RemoveNode ¶
RemoveNode removes specified node
func (*GLPeer) Reset ¶
func (glpeer *GLPeer) Reset()
Reset resets current gl context. All sprites are also cleaned. This is called at changing of scene, and this function is for clean previous scene.
func (*GLPeer) Update ¶
func (glpeer *GLPeer) Update(sc SpriteContainerer)
Update updates screen. This is called 60 times per 1 sec.
func (*GLPeer) ZIndexDirty ¶
func (glpeer *GLPeer) ZIndexDirty()
ZIndexDirty enables dirty flag. It indicates sorting of znodes is necessary because at least one of their zindex has been updated.
type GLer ¶
type GLer interface { // Initialize initializes GLPeer. // This function must be called in advance of using GLPeer Initialize(glc *GLContext) // LoadTexture return texture that is loaded by the information of arguments. // Loaded texture can assign using AddSprite function. LoadTexture(assetName string, rect image.Rectangle) sprite.SubTex // MakeTextureByText create and return texture by specified text // Loaded texture can assign using AddSprite function. // TODO: font parameterize MakeTextureByText(text string, fontsize float64, fontcolor color.RGBA, rect image.Rectangle) sprite.SubTex // Finalize finalizes GLPeer. // This is called at termination of application. Finalize() // Update updates screen. // This is called 60 times per 1 sec. Update(sc SpriteContainerer) // Reset resets current gl context. // All sprites are also cleaned. // This is called at changing of scene, and // this function is for clean previous scene. Reset() // NewTexture returns a new Texture instance NewTexture(s sprite.SubTex) *Texture // ReleaseTexture releases specified texture ReleaseTexture(t *Texture) // NewNode returns new node NewNode(fn arrangerFunc) *ZNode // AppendNode adds specified node as a child AppendNode(n *ZNode) // RemoveNode removes specified node RemoveNode(n *ZNode) // SetSubTex registers subtexture to specified node SetSubTex(n *ZNode, subTex *sprite.SubTex) // ZIndexDirty updates dirty flag with specified argument ZIndexDirty() }
GLer interface represents interface of GL
type Gomo ¶
type Gomo struct {
// contains filtered or unexported fields
}
Gomo represents gomobile instance.
func (*Gomo) Initialize ¶
Initialize initializes Gomo.
type Gomoer ¶
type Gomoer interface { // Initialize initializes Gomo. Initialize(onStart func(glc *GLContext), onStop func(), updateCallback func()) // Start starts gomobile's main loop. // Most of events handled by peer is fired by this function. Start() }
Gomoer represents an interface of gomobile
type ScreenSizer ¶
type ScreenSizer interface { // SetScreenSize sets device's actual screen size. // currently this function is called only from gomobile.go, // at updating window size, or orientating of screen. SetScreenSize(s size.Event) // SetDesiredScreenSize sets virtual screen size. // Any positive value can be specified to arguments. // like, w=1920, h=1080 SetDesiredScreenSize(w, h float32) }
ScreenSizer represents interface for configurating screen size
func GetScreenSizePeer ¶
func GetScreenSizePeer() ScreenSizer
GetScreenSizePeer returns an instance of ScreenSizer
type Sprite ¶
type Sprite struct { // W = width of sprite W float32 // H = height of sprite H float32 // X = x position of sprite X float32 // Y = y position of sprite Y float32 // R = radius of sprite (use for rotation) R float32 // contains filtered or unexported fields }
Sprite represents a sprite. Deprecated. this will be unexposed.
func (*Sprite) AddTouchListener ¶
func (s *Sprite) AddTouchListener(l TouchListener)
AddTouchListener registers a listener to notify touch event.
func (*Sprite) RemoveAllTouchListener ¶
func (s *Sprite) RemoveAllTouchListener()
RemoveAllTouchListener removes all registered listeners from sprite.
type SpriteContainer ¶
type SpriteContainer struct {
// contains filtered or unexported fields
}
SpriteContainer represents array of SpriteNodePair.
func (*SpriteContainer) AddSprite ¶
func (sc *SpriteContainer) AddSprite(s *Sprite, subTex *sprite.SubTex, arrangeCallback func()) error
AddSprite adds a sprite to SpriteContainer.
func (*SpriteContainer) GetSpriteNodePairs ¶
func (sc *SpriteContainer) GetSpriteNodePairs() *sync.Map
GetSpriteNodePairs returns map representation of sprite and node pair
func (*SpriteContainer) GetZIndex ¶
func (sc *SpriteContainer) GetZIndex(s *Sprite) (int, error)
GetZIndex returns specified sprite's zindex
func (*SpriteContainer) Initialize ¶
func (sc *SpriteContainer) Initialize(gl GLer)
Initialize initializes SpriteContainer object. This must be called to use all SpriteContainer's function in advance.
func (*SpriteContainer) OnTouchBegin ¶
func (sc *SpriteContainer) OnTouchBegin(x, y float32)
OnTouchBegin is called when screen is started to touch. This function calls listener's OnTouchBegin if the touched position is contained by sprite's rectangle.
func (*SpriteContainer) OnTouchEnd ¶
func (sc *SpriteContainer) OnTouchEnd(x, y float32)
OnTouchEnd is called when touch is ended (released). This function calls listener's OnTouchEnd if the touched position is contained by sprite's rectangle.
func (*SpriteContainer) OnTouchMove ¶
func (sc *SpriteContainer) OnTouchMove(x, y float32)
OnTouchMove is called when touch is moved (dragged). This function calls listener's OnTouchMove if the touched position is contained by sprite's rectangle.
func (*SpriteContainer) RemoveSprite ¶
func (sc *SpriteContainer) RemoveSprite(remove *Sprite)
RemoveSprite removes a specified sprite from SpriteContainer. Since Unregister of Node is not implemented by gomobile, this function just marks the specified sprite as "not in use". The sprite marked as "not in use" will be reused at AddSprite.
func (*SpriteContainer) RemoveSprites ¶
func (sc *SpriteContainer) RemoveSprites()
RemoveSprites removes all registered sprites from SpriteContainer.
func (*SpriteContainer) ReplaceTexture ¶
func (sc *SpriteContainer) ReplaceTexture(sprite *Sprite, texture *Texture)
ReplaceTexture replaces sprite's texture to specified one.
type SpriteContainerer ¶
type SpriteContainerer interface { // Initialize initializes SpriteContainer object. // This must be called to use all SpriteContainer's function in advance. Initialize(gl GLer) // AddSprite adds a sprite to SpriteContainer. AddSprite(s *Sprite, subTex *sprite.SubTex, arrangeCallback func()) error // RemoveSprite removes a specified sprite from SpriteContainer. // Since Unregister of Node is not implemented by gomobile, this function just // marks the specified sprite as "not in use". // The sprite marked as "not in use" will be reused at AddSprite. RemoveSprite(remove *Sprite) // RemoveSprites removes all registered sprites from SpriteContainer. RemoveSprites() // SetZIndex sets specified zindex to specified Sprite SetZIndex(sprite *Sprite, z int) error // GetZIndex returns specified sprite's zindex GetZIndex(sprite *Sprite) (int, error) // GetSpriteNodePairs returns map representation of sprite and node pair GetSpriteNodePairs() *sync.Map // ReplaceTexture replaces sprite's texture to specified one. ReplaceTexture(sprite *Sprite, texture *Texture) // OnTouchBegin is called when screen is started to touch. // This function calls listener's OnTouchBegin if the touched position is // contained by sprite's rectangle. OnTouchBegin(x, y float32) // OnTouchMove is called when touch is moved (dragged). // This function calls listener's OnTouchMove if the touched position is // contained by sprite's rectangle. OnTouchMove(x, y float32) // OnTouchEnd is called when touch is ended (released). // This function calls listener's OnTouchEnd if the touched position is // contained by sprite's rectangle. OnTouchEnd(x, y float32) }
SpriteContainerer represents an interface of SpriteContaienr
func GetSpriteContainer ¶
func GetSpriteContainer() SpriteContainerer
GetSpriteContainer returns SpriteContainer. Since SpriteContainer is singleton, use this function to get instance of SpriteContainer.
type Spriter ¶
type Spriter interface { // AddTouchListener registers a listener to notify touch event. AddTouchListener(l TouchListener) // RemoveAllTouchListener removes all registered listeners from sprite. RemoveAllTouchListener() }
Spriter represents interface of Sprite
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
Texture represents a texture object that contains subTex
type TouchListener ¶
type TouchListener interface { OnTouchBegin(x, y float32) OnTouchMove(x, y float32) OnTouchEnd(x, y float32) }
TouchListener is interface to be notified touch event.
type TouchPeer ¶
type TouchPeer struct {
// contains filtered or unexported fields
}
TouchPeer represents a Touch object. Singleton.
func (*TouchPeer) AddTouchListener ¶
func (tp *TouchPeer) AddTouchListener(listener TouchListener)
AddTouchListener registers a listener to notify touch event.
func (*TouchPeer) OnTouchBegin ¶
OnTouchBegin is called when touch is started. This event is notified to all registered listeners despite of the touched position.
func (*TouchPeer) OnTouchEnd ¶
OnTouchEnd is called when touch is ended (released). This event is notified to all registered listeners despite of the touched position.
func (*TouchPeer) OnTouchMove ¶
OnTouchMove is called when touch is moved (dragged). This event is notified to all registered listeners despite of the touched position.
func (*TouchPeer) RemoveAllTouchListeners ¶
func (tp *TouchPeer) RemoveAllTouchListeners()
RemoveAllTouchListeners removes all registered listeners.
func (*TouchPeer) RemoveTouchListener ¶
func (tp *TouchPeer) RemoveTouchListener(listener TouchListener)
RemoveTouchListener removes specified listener.
type Toucher ¶
type Toucher interface { // AddTouchListener registers a listener to notify touch event. AddTouchListener(listener TouchListener) // RemoveTouchListener removes specified listener. RemoveTouchListener(listener TouchListener) // RemoveAllTouchListener removes all registered listeners. RemoveAllTouchListeners() // OnTouchBegin is called when touch is started. // This event is notified to all registered listeners despite of the touched position. OnTouchBegin(pxx, pxy float32) // OnTouchMove is called when touch is moved (dragged). // This event is notified to all registered listeners despite of the touched position. OnTouchMove(pxx, pxy float32) // OnTouchEnd is called when touch is ended (released). // This event is notified to all registered listeners despite of the touched position. OnTouchEnd(pxx, pxy float32) }
Toucher represents an interface for touch controller
func GetTouchPeer ¶
func GetTouchPeer() Toucher
GetTouchPeer returns instance of TouchPeer. Since TouchPeer is singleton, it is necessary to call this function to get instance of TouchPeer.