Пример #1
0
func main() {
	// setup
	// ops := pixi.NewRendererOptions()
	// ops.Transparent = true
	// render = pixi.AutoDetectRenderer(800, 600, ops)
	render.BackgroundColor = 0x070202 // transparent works first
	sprites.Position.Set(400, 300)
	renderSprit.Anchor.SetTo(0.5)
	renderSprit.Position.Set(400, 300)
	stage.AddChild(sprites)
	stage.AddChild(renderSprit)
	stage.Interactive = true
	stage.HitArea = pixi.NewRectangle(0, 0, 800, 600)
	// load
	loadSprites()
	dom.OnDOMContentLoaded(func() {
		el := dom.Wrap(render.View)
		dom.Body().AppendChild(el)
		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(0)
	})
}
Пример #2
0
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)
	})
}
Пример #3
0
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()
	})
}