Ejemplo n.º 1
0
Archivo: main.go Proyecto: govlas/pixi
func main() {
	stage.Interactive = true
	stage.On(pixi.EventClick, handler)
	g := newBall()
	stage.AddChild(g)
	dom.OnDOMContentLoaded(func() {
		renderer = pixi.AutoDetectRenderer(dom.Window().InnerWidth, dom.Window().InnerHeight)
		renderer.BackgroundColor = 0xffffff
		stage.HitArea = pixi.NewRectangle(0, 0, renderer.Width, renderer.Height)
		v := dom.Wrap(renderer.View)
		v.Width = dom.Window().InnerWidth
		v.Height = dom.Window().InnerHeight
		dom.Body().AppendChild(v)
		raf.RequestAnimationFrame(run)
	})
}
Ejemplo n.º 2
0
Archivo: main.go Proyecto: govlas/pixi
func main() {
	stage.Interactive = true
	// stage.AddChild(ctx)
	stage.On(pixi.EventMouseMove, func(ed *pixi.InteractionEvent) {
		id := ed.Data
		makeParticles(id.Global.X, id.Global.Y, 4)
	})
	dom.OnDOMContentLoaded(func() {
		dom.Body().Style.SetProperty("margin", "0")
		renderer = pixi.AutoDetectRenderer(dom.Window().InnerWidth, dom.Window().InnerHeight)
		v := dom.Wrap(renderer.View)
		v.Width = dom.Window().InnerWidth
		v.Height = dom.Window().InnerHeight
		dom.Body().AppendChild(v)
		raf.RequestAnimationFrame(run)
	})
}
Ejemplo n.º 3
0
Archivo: main.go Proyecto: govlas/pixi
func main() {
	ops := pixi.NewRendererOptions()
	ops.Transparent = true
	render = pixi.AutoDetectRenderer(300, 300, ops)
	stage.Interactive = true
	stage.HitArea = pixi.NewRectangle(0, 0, 300, 300)
	render.BackgroundColor = 0xff0000 // transparent works first
	render.Transparent = true
	dom.OnDOMContentLoaded(func() {
		dom.Body().Style.SetProperty("background", "blue")
		stage.On(pixi.EventClick, func(ed *pixi.InteractionEvent) {
			println("EventClick", ed.Data.Global)
		}).On(pixi.EventMouseClick, func(ed *pixi.InteractionEvent) {
			println("EventMouseClick", ed.Data.Global)
		}).On(pixi.EventMouseUp, func(ed *pixi.InteractionEvent) {
			println("EventMouseUp", ed.Data.Global)
		})
		run()
	})
}
Ejemplo n.º 4
0
Archivo: main.go Proyecto: govlas/pixi
package main

import (
	"github.com/Archs/js/dom"
	"github.com/Archs/js/raf"
	"github.com/Archs/pixi"
	"github.com/gopherjs/gopherjs/js"
	"math"
)

var (
	stage    = pixi.NewContainer()
	renderer = pixi.AutoDetectRenderer(800, 600)
)

func run(t float64) {
	raf.RequestAnimationFrame(run)
	renderer.Render(stage)
}

func main() {
	txt := pixi.NewText("A Text Object will create a line or multiple lines of text. \nTo split a line you can use '\\n' in your text string, or add a wordWrap property set to true and and wordWrapWidth property with a value in the style object.", js.M{
		"font":               "36px Arial bold italic",
		"fill":               "#F7EDCA",
		"stroke":             "#4a1850",
		"strokeThickness":    5,
		"dropShadow":         true,
		"dropShadowColor":    "#000000",
		"dropShadowAngle":    math.Pi / 6,
		"dropShadowDistance": 6,
		"wordWrap":           true,
Ejemplo n.º 5
0
Archivo: main.go Proyecto: govlas/pixi
	"github.com/Archs/js/raf"
	"github.com/Archs/pixi"

	"github.com/gopherjs/gopherjs/js"
)

var (
	width  = 1024.0
	height = 728.0
	slideX = width / 2
	slideY = height / 2
	sx     = 1.0
	sy     = 1.0

	stage    = pixi.NewContainer()
	renderer = pixi.AutoDetectRenderer(int(width), int(height))
	texture  = pixi.TextureFromImage("bubble_32x32.png", false, pixi.ScaleModes.Default)
	balls    = make([]*Ball, 0)
)

type Ball struct {
	sprite *pixi.Sprite
	x, y   float64
}

func animate(t float64) {
	for i := 0; i < len(balls); i++ {
		ball := balls[i]
		ball.sprite.Position.X = ball.x + slideX
		ball.sprite.Position.Y = ball.y + slideY
		ball.x *= sx
Ejemplo n.º 6
0
Archivo: main.go Proyecto: govlas/pixi
package main

import (
	"github.com/Archs/js/raf"
	"github.com/Archs/pixi"

	"github.com/gopherjs/gopherjs/js"
)

var (
	stage      = pixi.NewContainer()
	renderer   = pixi.AutoDetectRenderer(620, 400)
	background = pixi.SpriteFromImage("bg.jpg", true, pixi.ScaleModes.Default)
	buttons    = make([]*Button, 0)
)

type Button struct {
	*pixi.Sprite
	isDown  bool
	isOver  bool
	upTex   *pixi.Texture
	downTex *pixi.Texture
	overTex *pixi.Texture
}

func NewButton(x, y float64, upTex, downTex, overTex *pixi.Texture) *Button {
	sprite := pixi.NewSprite(upTex)
	sprite.ButtonMode = true

	sprite.Anchor.SetTo(0.5)
	sprite.Position.Set(x, y)
Ejemplo n.º 7
0
Archivo: main.go Proyecto: govlas/pixi
package main

import (
	"github.com/Archs/js/raf"
	"github.com/Archs/pixi"

	"github.com/gopherjs/gopherjs/js"
)

var (
	stage    = pixi.NewContainer()
	renderer = pixi.AutoDetectRenderer(400, 300)
	texture  = pixi.TextureFromImage("bunny.png", true, pixi.ScaleModes.Default)
	bunny    = pixi.NewSprite(texture)
)

func animate(t float64) {
	raf.RequestAnimationFrame(animate)
	bunny.Rotation += 0.1
	renderer.Render(stage)
}

func main() {
	js.Global.Get("document").Get("body").Call("appendChild", renderer.View)
	renderer.BackgroundColor = 0x66FF99
	bunny.Anchor.SetTo(0.5)
	bunny.Position.Set(200, 150)

	stage.AddChild(bunny)

	raf.RequestAnimationFrame(animate)