peer

package
v0.0.0-...-3c69f0b Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FitHeight indicates screen should fit to height length
	FitHeight = iota
	// FitWidth indicates screen should fit to width length
	FitWidth
)

Variables

This section is empty.

Functions

func GetScreenSize

func GetScreenSize() size.Event

GetScreenSize returns screen size of device. This value is set by SetScreenSize in advance.

func LogDebug

func LogDebug(format string, a ...interface{})

LogDebug prints logs. This is disabled at Release Build.

func LogError

func LogError(format string, a ...interface{})

LogError prints logs. This is never disabled even for Release build.

func SetDesiredScreenSize

func SetDesiredScreenSize(w, h float32)

SetDesiredScreenSize sets virtual screen size. Any positive value can be specified to arguments. like, w=1920, h=1080

func SetScreenSize

func SetScreenSize(s size.Event)

SetScreenSize sets screen size of device. This will be called only from gomobile.go.

Types

type GLPeer

type GLPeer struct {
	// contains filtered or unexported fields
}

GLPeer represents gl context. Singleton.

func GetGLPeer

func GetGLPeer() *GLPeer

GetGLPeer returns a instance of GLPeer. Since GLPeer is singleton, it is necessary to call this function to get GLPeer instance.

func (*GLPeer) Finalize

func (glpeer *GLPeer) Finalize()

Finalize finalizes GLPeer. This is called at termination of application.

func (*GLPeer) Initialize

func (glpeer *GLPeer) Initialize(glctx gl.Context)

Initialize initializes GLPeer. This function must be called inadvance of using GLPeer

func (*GLPeer) LoadTexture

func (glpeer *GLPeer) LoadTexture(assetName string, rect image.Rectangle) sprite.SubTex

LoadTexture return texture that is loaded by the information of arguments. Loaded texture can assign using AddSprite function.

func (*GLPeer) LoadTextureFromImage

func (glpeer *GLPeer) LoadTextureFromImage(img image.Image, rect image.Rectangle) sprite.SubTex

LoadTextureFromImage return texture that is loaded by the information of arguments. Loaded texture can assign using AddSprite function.

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()

Update updates screen. This is called 60 times per 1 sec.

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.

func (*Sprite) AddTouchListener

func (sprite *Sprite) AddTouchListener(listener TouchListener)

AddTouchListener registers a listener to notify touch event.

func (*Sprite) RemoveAllTouchListener

func (sprite *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 GetSpriteContainer

func GetSpriteContainer() *SpriteContainer

GetSpriteContainer returns SpriteContainer. Since SpriteContainer is singleton, use this function to get instance of SpriteContainer.

func (*SpriteContainer) AddSprite

func (spritecontainer *SpriteContainer) AddSprite(s *Sprite, subTex sprite.SubTex)

AddSprite adds a sprite to SpriteContainer.

func (*SpriteContainer) Initialize

func (spritecontainer *SpriteContainer) Initialize()

Initialize initializes SpriteContainer object. This must be called to use all SpriteContainer's function in advance.

func (*SpriteContainer) OnTouchBegin

func (spritecontainer *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 (spritecontainer *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 (spritecontainer *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 (spritecontainer *SpriteContainer) RemoveSprite(remove *Sprite)

RemoveSprite removes a spcified 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 (spritecontainer *SpriteContainer) RemoveSprites()

RemoveSprites removes all registered sprites from SpriteContainer.

func (*SpriteContainer) ReplaceTexture

func (spritecontainer *SpriteContainer) ReplaceTexture(sprite *Sprite, subTex sprite.SubTex)

ReplaceTexture replaces sprite's texture to specified one.

type SpriteNodePair

type SpriteNodePair struct {
	// contains filtered or unexported fields
}

SpriteNodePair represents pair of Sprite and sprite.Node. This is used for calculate affine transformation of Node from Sprite's property.

type TouchListener

type TouchListener interface {
	OnTouchBegin(x, y float32)
	OnTouchMove(x, y float32)
	OnTouchEnd(x, y float32)
}

TouchListener is interface to be notifed touch event.

type TouchPeer

type TouchPeer struct {
	// contains filtered or unexported fields
}

TouchPeer represents a Touch object. Singleton.

func GetTouchPeer

func GetTouchPeer() *TouchPeer

GetTouchPeer returns instance of TouchPeer. Since TouchPeer is singleton, it is necessary to call this function to get instance of TouchPeer.

func (*TouchPeer) AddTouchListener

func (touchpeer *TouchPeer) AddTouchListener(listener TouchListener)

AddTouchListener registeres a listener to notify touch event.

func (*TouchPeer) OnTouchBegin

func (touchpeer *TouchPeer) OnTouchBegin(pxx, pxy float32)

OnTouchBegin is called when touch is started. This event is notified to all registered listeners despite of the touched position.

func (*TouchPeer) OnTouchEnd

func (touchpeer *TouchPeer) OnTouchEnd(pxx, pxy float32)

OnTouchEnd is called when touch is ended (released). This event is notified to all registered listeners despite of the touched position.

func (*TouchPeer) OnTouchMove

func (touchpeer *TouchPeer) OnTouchMove(pxx, pxy float32)

OnTouchMove is called when touch is moved (dragged). This event is notified to all registered listeners despite of the touched position.

func (*TouchPeer) RemoveAllTouchListener

func (touchpeer *TouchPeer) RemoveAllTouchListener()

RemoveAllTouchListener removes all registered listeners.

func (*TouchPeer) RemoveTouchListener

func (touchpeer *TouchPeer) RemoveTouchListener(listener TouchListener)

RemoveTouchListener removes specified listener.

Jump to

Keyboard shortcuts

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