예제 #1
0
파일: main.go 프로젝트: govlas/pixi
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
파일: main.go 프로젝트: govlas/pixi
func main() {
	dom.OnDOMContentLoaded(func() {
		el := dom.Wrap(renderer.View)
		dom.Body().AppendChild(el)
		raf.RequestAnimationFrame(animate)
	})
}
예제 #3
0
파일: main.go 프로젝트: govlas/pixi
func main() {
	renderer.BackgroundColor = 0xffffff
	stage.AddChild(tilingSprite)
	dom.OnDOMContentLoaded(func() {
		el := dom.Wrap(renderer.View)
		dom.Body().AppendChild(el)
		raf.RequestAnimationFrame(run)
	})
}
예제 #4
0
파일: main.go 프로젝트: govlas/pixi
func main() {
	snake1 := newSnake()
	snake1.Position.Set(0, 120)
	snake2 := newSnake()
	snake2.Position.Set(120, 300)
	stage.AddChild(snake1, snake2)
	dom.OnDOMContentLoaded(func() {
		el := dom.Wrap(renderer.View)
		dom.Body().AppendChild(el)
		raf.RequestAnimationFrame(animate)
	})
}
예제 #5
0
파일: main.go 프로젝트: govlas/pixi
func main() {
	if renderer.Type == pixi.RendererType.WEBGL {
		maggotNum = 1000
	}
	rand.Seed(time.Now().UnixNano())
	for i := 0; i < maggotNum; i++ {
		sprites.AddChild(newMaggot())
	}
	stage.AddChild(sprites)
	dom.OnDOMContentLoaded(func() {
		el := dom.Wrap(renderer.View)
		dom.Body().AppendChild(el)
		raf.RequestAnimationFrame(animate)
	})
}
예제 #6
0
파일: main.go 프로젝트: 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)
	})
}
예제 #7
0
파일: main.go 프로젝트: 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)
	})
}
예제 #8
0
파일: main.go 프로젝트: 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()
	})
}
예제 #9
0
func main() {
	dom.OnDOMContentLoaded(func() {
		s := dom.GetElementById("gopherjs")
		style := dom.GetComputedStyle(s)

		el := canvas.New(dom.CreateElement("canvas").Object)
		cw, _ = strconv.ParseFloat(style.GetPropertyValue("width")[:3], 64)
		ch, _ = strconv.ParseFloat(style.GetPropertyValue("height")[:3], 64)
		el.Width = int(cw)
		el.Height = int(ch)
		el.AddEventListener(dom.EvtMousemove, func(e *dom.Event) {
			e.PreventDefault()
			x := float64(e.LayerX)
			y := float64(e.LayerY)
			makeParticles(x, y, 5)
		})
		ctx = el.GetContext2D()
		ctx.GlobalCompositeOperation = canvas.CompositeLighter
		s.AppendChild(el.Element)
		raf.RequestAnimationFrame(run)
	})
}
예제 #10
0
파일: main.go 프로젝트: govlas/pixi
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,
		"wordWrapWidth":      500,
	})
	txt.Anchor.SetTo(0)
	txt.Position.Set(20, 20)
	stage.AddChild(txt)
	renderer.BackgroundColor = 0x1099bb
	dom.OnDOMContentLoaded(func() {
		el := dom.Wrap(renderer.View)
		dom.Body().AppendChild(el)
		raf.RequestAnimationFrame(run)
	})
}
예제 #11
0
파일: main.go 프로젝트: govlas/pixi
func main() {
	dom.OnDOMContentLoaded(func() {
		s := dom.Body()
		// set full window and black background
		s.Style.SetProperty("margin", "0")
		s.Style.SetProperty("background", "#222")

		el := canvas.New(dom.CreateElement("canvas").Object)
		cw = float64(dom.Window().InnerWidth)
		ch = float64(dom.Window().InnerHeight)
		el.Width = int(cw)
		el.Height = int(ch)
		el.AddEventListener(dom.EvtMousemove, func(e *dom.Event) {
			e.PreventDefault()
			x := float64(e.ClientX)
			y := float64(e.ClientY)
			makeParticles(x, y, 5)
		})
		ctx = el.GetContext2D()
		ctx.GlobalCompositeOperation = canvas.CompositeLighter
		dom.Body().AppendChild(el.Element)
		raf.RequestAnimationFrame(run)
	})
}
예제 #12
0
파일: test.go 프로젝트: theclapp/js
func main() {
	dom.OnDOMContentLoaded(func() {
		test()
	})
}