gocos2d

package module
v0.0.0-...-b979507 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2013 License: MIT Imports: 14 Imported by: 0

README

Gocos2D

Introduction:

Gocos2D is a Google Go(lang) game development library based on the popular Cocos2D video game sdk. For those who are unfamiliar with Cocos2D, the design philosophy behind the project is that it intends to simplify game development. One way it does this is by providing objects called singletons that handle openGL commands and initialization for you; effectively simplifying the game development experience drastically.

Here is an example of what the Cocos2D/Gocos2D experience is like in regards to the singletons.

The main singleton is called the director. The director's job is to handle your games scenes for you. You can pass the director a scene that contains all your sprites and scene related logic; then the director pushes it onto the scene stack. The director will then draw your scene to the openGL context while updating your game logic for you. If the director is commanded to swap scenes with another, for instance when you beat level 1 and need to start level 2, the director pops level 1 off the stack. Which the garbage collector then collects the popped scene and the director starts the entire process all over again but this time with the current scene pointer pointing at level 2's scene.

Documentation

Overview

http://mortdeus.mit-license.org/

http://mortdeus.mit-license.org/

http://mortdeus.mit-license.org/

Index

Constants

View Source
const (
	WorldSpace = iota
	NodeSpace
	AnchorRelative
)
View Source
const (
	POSITION_COLOR_FRAG = `` /* 258-byte string literal not displayed */

	POSITION_COLOR_VERT = `` /* 373-byte string literal not displayed */

	POSITION_UCOLOR_FRAG = `` /* 317-byte string literal not displayed */

	POSITION_UCOLOR_VERT = `` /* 516-byte string literal not displayed */

	POSITION_COLOR_LENGTH_TEXTURE_FRAG = `` /* 195-byte string literal not displayed */

	POSITION_COLOR_LENGTH_TEXTURE_VERT = `` /* 447-byte string literal not displayed */

	POSITION_TEXTURE_FRAG = `` /* 391-byte string literal not displayed */

	POSITION_TEXTURE_VERT = `` /* 457-byte string literal not displayed */

	POSITION_TEXTURE_UCOLOR_FRAG = `` /* 551-byte string literal not displayed */

	POSITION_TEXTURE_UCOLOR_VERT = `` /* 465-byte string literal not displayed */

	POSITION_TEXTURE_A8COLOR_FRAG = `` /* 659-byte string literal not displayed */

	POSITION_TEXTURE_A8COLOR_VERT = `` /* 621-byte string literal not displayed */

	POSITION_TEXTURE_COLOR_FRAG = `` /* 473-byte string literal not displayed */

	POSITION_TEXTURE_COLOR_VERT = `` /* 618-byte string literal not displayed */

	POSITION_TEXTURE_COLOR_ALPHATEST_FRAG = `` /* 936-byte string literal not displayed */

	EX_SWITCHMASK_FRAG = `` /* 809-byte string literal not displayed */

)

Variables

View Source
var Director = new(director)

The Director is a singleton that is designed to simplify how you manage your game. It is used to initialize a openGL context and It maintains a stack of scenes. You are able to update and draw your scenes directly by calling Director.Update and Director.Draw in your game loop.

View Source
var Identity = &affineTransform{A: 1, D: 1}

Functions

func IsLineIntersect

func IsLineIntersect(a, b, c, d Point, s_t *struct{ S, T float32 }) bool

func IsLineOverlap

func IsLineOverlap(a, b, c, d Point) bool

func IsLineParallel

func IsLineParallel(a, b, c, d Point) bool

func IsSegmentIntersect

func IsSegmentIntersect(a, b, c, d Point) bool

func IsSegmentOverlap

func IsSegmentOverlap(a, b, c, d Point, s_e []Point) bool

func NewLayer

func NewLayer(tag string, z float32) *layer

func NewNode

func NewNode(tag string) *node

func NewScene

func NewScene(tag string) *scene

func NewShader

func NewShader(s string, typ uint) (shader uint)

func NewSprite

func NewSprite(tag string, r io.Reader) *sprite

func Program

func Program(vsh, fsh uint) uint

Types

type Action

type Action interface {
	Step()
	Stop()
	Update()
	Func(Node)
}

func NewAction

func NewAction(fn func(Node)) Action

type ActionManager

type ActionManager interface {
	Register(string, Action)
	Call(string, Node)
	Run(func(Node))

	Pause()
	Resume()
}

func NewActionManager

func NewActionManager() ActionManager

type AffineTarget

type AffineTarget interface {
	Apply(affineTransform) AffineTarget
}

type AffineTransform

type AffineTransform interface {
	Translate(tx, ty float32) AffineTransform
	Scale(sx, sy float32) AffineTransform
	Rotate(angle float32) AffineTransform
	Concat(t2 struct{ A, B, C, D, Tx, Ty float32 }) AffineTransform
	Equal(t2 struct{ A, B, C, D, Tx, Ty float32 }) bool
	Invert() AffineTransform
}

type Layer

type Layer interface {
	Node
}

type Node

type Node interface {
	sync.Locker

	Tag() string
	IsVisible() bool
	IsDirty() (bool, bool)

	Update() error
	Draw() error
	OnEnter() error
	OnExit() error
	Cleanup() error
	Visit() error

	Transform(uint) error

	WorldToNodeTransform() AffineTransform
	NodeToWorldTransform() AffineTransform
	ParentToNodeTransform() AffineTransform
	NodeToParentTransform() AffineTransform

	ConvertTo(struct{ X, Y float32 }, uint) (struct{ X, Y float32 }, error)

	GetParent() Node
	SetParent(Node)

	AddChild(string, Node)
	GetChild(string) Node
	RemoveChild(string)
}

type ParticleSystem

type ParticleSystem interface {
	Node
}

type Point

type Point struct{ X, Y float32 }

func ForAngle

func ForAngle(a float32) Point

func IntersectPoint

func IntersectPoint(a, b, c, d Point) Point

func (Point) Angle

func (p Point) Angle(p2 Point) float32

func (Point) Apply

func (p Point) Apply(t struct{ A, B, C, D, Tx, Ty float32 }) Point

func (Point) ClampPoint

func (p Point) ClampPoint(min, max Point) Point

func (Point) CompOp

func (p Point) CompOp(f func(float32) float32) Point

func (Point) Cross

func (p Point) Cross(p2 Point) float32

func (Point) Dot

func (p Point) Dot(p2 Point) float32

func (Point) Equals

func (p Point) Equals(p2 Point) bool

func (Point) FuzzyEquals

func (p Point) FuzzyEquals(p2 Point, v float32) bool

func (Point) Len

func (p Point) Len() float32

func (*Point) Lerp

func (p *Point) Lerp(p2 Point, alpha float32) Point

func (Point) Midpoint

func (p Point) Midpoint(p2 Point) Point

func (Point) Normalize

func (p Point) Normalize() Point

func (Point) Perp

func (p Point) Perp() Point

func (Point) Project

func (p Point) Project(p2 Point) Point

func (Point) RPerp

func (p Point) RPerp() Point

func (Point) Rotate

func (p Point) Rotate(p2 Point) Point

func (Point) RotateByAngle

func (p Point) RotateByAngle(pivot Point, angle float32) Point

func (*Point) SetPoint

func (p *Point) SetPoint(x, y float32)

func (Point) Unrotate

func (p Point) Unrotate(p2 Point) Point

type Rect

type Rect struct {
	Point
	Size
}

func (Rect) Apply

func (r Rect) Apply(t struct{ A, B, C, D, Tx, Ty float32 }) Rect

func (Rect) ContainsPoint

func (r Rect) ContainsPoint(p Point) bool

func (Rect) Equals

func (r Rect) Equals(r2 Rect) bool

func (Rect) IntersectsRect

func (r Rect) IntersectsRect(r2 Rect) bool

func (Rect) MaxX

func (r Rect) MaxX() float32

func (Rect) MaxY

func (r Rect) MaxY() float32

func (Rect) MidX

func (r Rect) MidX() float32

func (Rect) MidY

func (r Rect) MidY() float32

func (Rect) MinX

func (r Rect) MinX() float32

func (Rect) MinY

func (r Rect) MinY() float32

func (*Rect) SetRect

func (r *Rect) SetRect(x, y, w, h float32)

func (Rect) UnionWithRect

func (r Rect) UnionWithRect(r2 Rect) Rect

type Scene

type Scene interface {
	Node
	AddLayer(Layer)
}

type Scheduler

type Scheduler interface {
	Schedule() error
	Unschedule() error
}

func NewScheduler

func NewScheduler() Scheduler

type Shader

type Shader interface {
	GetShader(uint) uint
	SetShader(uint, uint)
}

type Size

type Size struct{ W, H float32 }

func (Size) Apply

func (s Size) Apply(t struct{ A, B, C, D, Tx, Ty float32 }) Size

func (Size) Equals

func (sz Size) Equals(sz2 Size) bool

func (*Size) SetSize

func (sz *Size) SetSize(w, h float32)

type Sprite

type Sprite interface {
	Node
}

Directories

Path Synopsis
doc
examples
gophers
http://mortdeus.mit-license.org/
http://mortdeus.mit-license.org/

Jump to

Keyboard shortcuts

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