pkg

package
v0.0.0-...-21449c0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT Imports: 55 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagNameDebug = "debug"
	FlagDescDebug = "print debug info"
)
View Source
const (
	FlagNameProfileCPU = "cpuprofile"
	FlagDescProfileCPU = "write cpu profile to file"
)
View Source
const (
	FlagNameTrace = "trace"
	FlagDescTrace = "write trace to file"
)
View Source
const (
	DefaultSceneTickRate = 60
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Director

type Director struct {
	*akara.World
	Events *eventemitter.EventEmitter

	Sys        DirectorSystems
	Components DirectorComponents
	// contains filtered or unexported fields
}

Director provides a scene management abstraction, with supporting systems. scenes are basically a superset of the functionality provided by an akara.System, but with a bunch of object creation facilities provided for free.

func New

func New() *Director

New creates a new director instance, with default settings

func (*Director) AddLuaScene

func (d *Director) AddLuaScene(key, path string)

AddLuaScene creates and adds a scene using a lua script

func (*Director) AddLuaSystem

func (d *Director) AddLuaSystem(path string)

AddLuaSystem creates and adds a scene using a lua script

func (*Director) AddScene

func (d *Director) AddScene(scene SceneInterface)

AddScene adds a scene

func (*Director) AddSystem

func (d *Director) AddSystem(sys akara.System)

AddScene adds a scene

func (*Director) ExportToLua

func (d *Director) ExportToLua(state *lua.LState, table *lua.LTable) *lua.LTable

func (*Director) RemoveScene

func (d *Director) RemoveScene(key string) *Director

RemoveScene queues a scene for removal

func (*Director) Run

func (d *Director) Run() error

func (*Director) Stop

func (d *Director) Stop()

Stop deactivates all the Director's systems

func (*Director) Update

func (d *Director) Update(dt time.Duration) (err error)

Update calls World.Update()

type DirectorComponents

type DirectorComponents struct {
	Audio            *audio.Component
	Interactive      *interactive.Component
	Viewport         *viewport.Component
	Camera           *camera.Camera
	Color            *color.Color
	Debug            *debug.Component
	FileLoadRequest  *fileLoadRequest.Component
	FileLoadResponse *fileLoadResponse.Component
	FileType         *fileType.Component
	Fill             *fill.Component
	HasChildren      *hasChildren.Component
	Animation        *animation.Component
	Stroke           *stroke.Component
	Font             *font.Component
	Opacity          *opacity.Component
	Origin           *origin.Component
	RenderTexture    *renderTexture.Component
	RenderOrder      *renderOrder.Component
	Size             *size.Component
	SceneGraphNode   *sceneGraphNode.Component
	Text             *text.Component
	Texture2D        *texture2D.Component
	Transform        *transform.Component
	Uuid             *uuid.Component
}

DirectorComponents contains all of the primitive components that come with director. These are INTENTIONALLY nil instances, which can be used when creating component filters. See akara's `World.NewComponentFilter` and `World.AddSubscription`

type DirectorSystems

type DirectorSystems struct {
	Load     *file_loader.System
	Renderer *renderer.System
	Texture  *texture_manager.System
	Tweens   *tween.System
	Input    *input.System
	Audio    *audio.System
}

DirectorSystems contains the base systems that are available when a director instance is created

func (DirectorSystems) ExportToLua

func (d DirectorSystems) ExportToLua(state *lua.LState, table *lua.LTable) *lua.LTable

type LuaScene

type LuaScene struct {
	Scene
	LuaScriptPath string
	// contains filtered or unexported fields
}

LuaScene is a graphical scene which is created purely from a lua script. The Lua script requires an init and update function be declared.

func NewLuaScene

func NewLuaScene(name, scriptPath string) *LuaScene

func (*LuaScene) Init

func (scene *LuaScene) Init(_ *akara.World)

func (*LuaScene) IsInitialized

func (scene *LuaScene) IsInitialized() bool

func (*LuaScene) Key

func (scene *LuaScene) Key() string

func (*LuaScene) Update

func (scene *LuaScene) Update()

type LuaSystem

type LuaSystem struct {
	SceneSystem
	LuaScriptPath string
	// contains filtered or unexported fields
}

LuaSystem is a non-graphical system which is created purely from a lua script. The Lua script requires an init and update function be declared.

func NewLuaSystem

func NewLuaSystem(scriptPath string) *LuaSystem

func (*LuaSystem) Init

func (sys *LuaSystem) Init(_ *akara.World)

func (*LuaSystem) IsInitialized

func (sys *LuaSystem) IsInitialized() bool

func (*LuaSystem) Update

func (sys *LuaSystem) Update()

type ObjectFactory

type ObjectFactory struct {
	common.SceneComponents
	// contains filtered or unexported fields
}

func (*ObjectFactory) Camera

func (factory *ObjectFactory) Camera(x, y, w, h int) akara.EID

func (*ObjectFactory) Circle

func (factory *ObjectFactory) Circle(x, y, radius int, fill, stroke color.Color) akara.EID

func (*ObjectFactory) Image

func (factory *ObjectFactory) Image(uri string, x, y int) akara.EID

func (*ObjectFactory) Label

func (factory *ObjectFactory) Label(str string, x, y, size int, fontName string, c color.Color) akara.EID

func (*ObjectFactory) Layer

func (factory *ObjectFactory) Layer(x, y int) akara.EID

func (*ObjectFactory) Rectangle

func (factory *ObjectFactory) Rectangle(x, y, w, h int, fill, stroke color.Color) akara.EID

func (*ObjectFactory) Sound

func (factory *ObjectFactory) Sound(filePath string, paused bool, volume float64, muted bool, loop bool, speedMultiplier float64) akara.EID

func (*ObjectFactory) Viewport

func (factory *ObjectFactory) Viewport(x, y, w, h int) akara.EID

type Scene

type Scene struct {
	SceneSystem
	Graph scenegraph.Node

	Viewports []akara.EID
	// contains filtered or unexported fields
}

Scene is the basic scene struct, intended to be embedded in an end-user's scenes. This scene "class" has most of the generic scene lifecycle stuff required, so it is recommended that it's always used to create new scenes (for now).

func (*Scene) ExportToLua

func (s *Scene) ExportToLua(state *lua.LState, table *lua.LTable) *lua.LTable

func (*Scene) GenericSceneInit

func (s *Scene) GenericSceneInit(d *Director)

func (*Scene) GenericUpdate

func (s *Scene) GenericUpdate()

func (*Scene) Name

func (s *Scene) Name() string

func (*Scene) RemoveEntity

func (s *Scene) RemoveEntity(e akara.EID)

func (*Scene) Render

func (s *Scene) Render()

type SceneInterface

type SceneInterface interface {
	akara.System

	Key() string
	Render()
	// contains filtered or unexported methods
}

SceneInterface represents what director considers to be a scene

type SceneSystem

type SceneSystem struct {
	*Director
	akara.BaseSystem
	Lua        *lua.LState
	Components common.SceneComponents
	Add        ObjectFactory
}

SceneSystem is the generic non-graphical stuff for a scene. This is kept separate so that non-graphical scenes can be created, such as for headless servers. This type of "scene" can still create objects, but is much more like a system in that it just inits and then does an update every tick.

Example 1: You could have many modal ui menus, and a system that manages state for all of these ui's.

Example 2: A scene that spawns objects with velocities, and another system that only uses the velocity to update their position every tick.

func (*SceneSystem) ExportToLua

func (s *SceneSystem) ExportToLua(state *lua.LState, table *lua.LTable) *lua.LTable

func (*SceneSystem) InitializeLua

func (s *SceneSystem) InitializeLua()

func (*SceneSystem) IsInitialized

func (s *SceneSystem) IsInitialized() bool

func (*SceneSystem) LuaInitialized

func (s *SceneSystem) LuaInitialized() bool

func (*SceneSystem) UninitializeLua

func (s *SceneSystem) UninitializeLua()

Jump to

Keyboard shortcuts

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