Exemple #1
0
func main() {
	js.Global.Get("document").Get("body").Call("appendChild", renderer.View)

	stage.AddChild(background)

	upTex := pixi.TextureFromImage("buttonUp.png", true, pixi.ScaleModes.Default)
	downTex := pixi.TextureFromImage("buttonDown.png", true, pixi.ScaleModes.Default)
	overTex := pixi.TextureFromImage("buttonOver.png", true, pixi.ScaleModes.Default)

	coords := []float64{
		175.0, 75.0,
		600 - 145, 75,
		600/2 - 20, 400/2 + 10,
		175, 400 - 75,
		600 - 115, 400 - 95,
	}

	for i := 0; i < len(coords)/2; i++ {
		button := NewButton(coords[i*2], coords[i*2+1], upTex, downTex, overTex)
		stage.AddChild(button)
		buttons = append(buttons, button)
	}

	buttons[0].Scale.X = 1.2
	buttons[1].Scale.Y = 1.2
	buttons[2].Rotation = 0.314159
	buttons[3].Scale.SetTo(0.8)
	buttons[4].Scale.Set(0.8, 1.2)
	buttons[4].Rotation = 3.14159

	raf.RequestAnimationFrame(animate)
}
Exemple #2
0
func newSnake() *Snake {
	s := new(Snake)
	s.ropeLen = snakeLen / 20.0
	s.counter = 0
	s.Points = make([]*pixi.Point, 0)
	for i := 0; i < 20; i++ {
		s.Points = append(s.Points, pixi.NewPoint(float64(i)*s.ropeLen, 0))
	}
	s.Texture = pixi.TextureFromImage("img/snake.png", false, pixi.ScaleModes.Default)
	s.Rope = pixi.NewRope(s.Texture, s.Points)
	s.Scale.SetTo(0.2)
	s.Update = s.roll
	return s
}
Exemple #3
0
	"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
		ball.y *= sy
Exemple #4
0
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)
Exemple #5
0
package main

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

var (
	stage        = pixi.NewContainer()
	renderer     = pixi.AutoDetectRenderer(800, 600)
	texture      = pixi.TextureFromImage("img/p2.jpeg", false, pixi.ScaleModes.Default)
	tilingSprite = pixi.NewTilingSprite(texture, renderer.Width, renderer.Height)

	counter = 0.05
)

func run(t float64) {
	counter += 0.05
	raf.RequestAnimationFrame(run)
	tilingSprite.TileScale.Set(math.Sin(counter)+2, math.Cos(counter)+2)
	tilingSprite.TilePosition.X += 1
	tilingSprite.TilePosition.Y += 1
	renderer.Render(stage)
}

func main() {
	renderer.BackgroundColor = 0xffffff
	stage.AddChild(tilingSprite)
	dom.OnDOMContentLoaded(func() {