本文整理匯總了Golang中github.com/jmorgan1321/golang-games/lib/engine/debug.Trace函數的典型用法代碼示例。如果您正苦於以下問題:Golang Trace函數的具體用法?Golang Trace怎麽用?Golang Trace使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Trace函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: StartUp
func (q *QmlDebugDrawer) StartUp(config types.JGameObject) {
defer debug.Trace().UnTrace()
qml.RegisterTypes("SqclDebugDrawExtensions", 1, 0, []qml.TypeSpec{{
Init: func(r *GoBox, obj qml.Object) {
r.Object = obj
},
}})
cfg := config.Comp("graphics.Config").(*Config)
file := `
import QtQuick 2.0
import SqclDebugDrawExtensions 1.0
Item {
property var box : Component {
Rectangle {
opacity: 0.5;
width: 100; height: 100;
border.width:5;
border.color:"blue";
}
}
}
`
component, err := cfg.Engine.LoadString("file.qml", strings.TrimSpace(file))
if err != nil {
panic(err)
}
q.Comp = component.Create(nil)
q.engine = cfg.Engine
q.window = cfg.Window
}
示例2: Paint
func (c *GoQmlRect) Paint(p *qml.Painter) {
defer debug.Trace().UnTrace()
gl := GL.API(p)
trans := c.R.Owner().Comp("physics.Transform").(*physics.Transform)
c.Set("x", trans.X)
c.Set("y", trans.Y)
width := float32(c.Int("width"))
height := float32(c.Int("height"))
gl.Enable(GL.BLEND)
gl.BlendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA)
gl.Color4f(1.0, 1.0, 1.0, 0.8)
gl.Begin(GL.QUADS)
gl.Vertex2f(0, 0)
gl.Vertex2f(width, 0)
gl.Vertex2f(width, height)
gl.Vertex2f(0, height)
gl.End()
gl.LineWidth(2.5)
gl.Color4f(0.0, 0.0, 0.0, 1.0)
gl.Begin(GL.LINES)
gl.Vertex2f(0, 0)
gl.Vertex2f(width, height)
gl.Vertex2f(width, 0)
gl.Vertex2f(0, height)
gl.End()
}
示例3: AddLine
func (q *QmlDebugDrawer) AddLine(goc types.JGameObject, x1, y1, x2, y2 int) {
defer debug.Trace().UnTrace()
if q.Object == nil {
q.Object = &GoBox{x1: x1, y1: y1, x2: x2, y2: y2}
q.Object.Init()
q.goc = goc
input := core.Core.Manager("QmlInputMngr").(types.JManager)
// TODO: how to unregister specific message?
// tracker := goc.Register("collision", input, func(e event.Data) {
goc.Register("collision", input, func(e event.Data) {
border := q.Object.Property("border").(qml.Object)
red := color.RGBA{255, 0, 0, 255}
if border.Color("color") == red {
border.Set("color", "blue")
} else {
border.Set("color", "red")
}
})
// goc.Unregister(tracker)
// tracker.Unlink()
} else {
q.Object.Deinit()
q.Object = nil
}
}
示例4: Init
func (c *GoBox) Init() {
defer debug.Trace().UnTrace()
grfx := core.Core.Manager("QmlDebugDrawer").(*QmlDebugDrawer)
c.Object = grfx.Comp.Object("box").Create(nil)
c.Set("parent", grfx.window.Root())
}
示例5: StartUp
func (q *QmlInputMngr) StartUp(config types.JGameObject) {
defer debug.Trace().UnTrace()
// cfg := config.Comp("input.Config").(*input.Config)
q.Register("register_input_comp", core.Core.RootSpace, func(e event.Data) {
q.registerInputHandler(e.(*InputHandler))
})
}
示例6: movePlayer
func (c *InputHandler) movePlayer(x, y int) {
defer debug.Trace().UnTrace()
trans := c.Owner().Comp("physics.Transform").(*physics.Transform)
trans.X += (10 * x)
trans.Y += (10 * y)
debug.Msg(trans.X, trans.Y)
}
示例7: EndFrame
func (q *QmlDebugDrawer) EndFrame() {
defer debug.Trace().UnTrace()
if q.Object != nil {
trans := q.goc.Comp("physics.Transform").(*physics.Transform)
q.Object.Set("x", trans.X)
q.Object.Set("y", trans.Y)
}
}
示例8: Init
func (t *Transform) Init() {
defer debug.Trace().UnTrace()
input := core.Core.Manager("QmlInputMngr").(types.JManager)
t.Owner().Register("debug_draw", input, func(e event.Data) {
t.DebugDraw()
})
}
示例9: EndFrame
func (q *QmlGrfxMngr) EndFrame() {
defer debug.Trace().UnTrace()
if q.r != nil {
trans := q.r.Owner().Comp("physics.Transform").(*physics.Transform)
q.r.Set("x", trans.X)
q.r.Set("y", trans.Y)
// // qml.Changed(q.r, fieldAddr)
}
}
示例10: StartUp
func (q *QmlGrfxMngr) StartUp(config types.JGameObject) {
defer debug.Trace().UnTrace()
types := []qml.TypeSpec{
{
Init: func(r *GoQmlRect, obj qml.Object) {
defer debug.Trace().UnTrace()
r.Object = obj
},
},
}
qml.RegisterTypes("GoExtensions", 1, 0, types)
cfg := config.Comp("graphics.Config").(*Config)
q.engine = cfg.Engine
q.window = cfg.Window
q.window.Set("width", cfg.W)
q.window.Set("height", cfg.H)
}
示例11: StartUp
func (c *core) StartUp(config JGameObjectHandle) {
defer debug.Trace().UnTrace()
for _, m := range c.managers {
m.StartUp(config)
}
for _, s := range c.spaces {
s.Init()
}
}
示例12: ShutDown
func (c *core) ShutDown() {
defer debug.Trace().UnTrace()
for i := len(c.spaces) - 1; i >= 0; i-- {
c.spaces[i].DeInit()
}
for i := len(c.managers) - 1; i >= 0; i-- {
c.managers[i].ShutDown()
}
}
示例13: HandleKey
// HandleKey handles keyboard events
func (q *QmlInputMngr) HandleKey(key int, shift_mod, ctrl_mod, alt_mod bool) {
defer debug.Trace().UnTrace()
switch keycodes.Keycode(key) {
case keycodes.Key_None:
// do nothing
case keycodes.Key_Alt, keycodes.Key_Shift, keycodes.Key_Control:
debug.Msg(keycodes.Keycode(key))
debug.Msg()
default:
// TODO(jemorgan): move this logic into input system
switch key {
case keycodes.Key_Right:
q.Dispatch("move_right", nil)
return
case keycodes.Key_Left:
q.Dispatch("move_left", nil)
return
case keycodes.Key_Up:
q.Dispatch("move_up", nil)
return
case keycodes.Key_Down:
q.Dispatch("move_down", nil)
return
case keycodes.Key_D:
q.Dispatch("debug_draw", nil)
case keycodes.Key_F:
q.Dispatch("collision", nil)
}
if shift_mod && key != keycodes.Key_Shift {
debug.Msg("shift+")
}
if ctrl_mod && key != keycodes.Key_Control {
debug.Msg("ctrl+")
}
if alt_mod && key != keycodes.Key_Alt {
debug.Msg("alt+")
}
debug.Msg(keycodes.Keycode(key))
debug.Msg()
}
if shift_mod && key == keycodes.Key_Q {
os.Exit(1)
}
// if key == keycodes.Key_T {
// ctrl.Timer.Set("running", true)
// }
}
示例14: Init
func (c *GoRect) Init() {
defer debug.Trace().UnTrace()
grfx := core.Core.Manager("QmlGrfxMngr").(*QmlGrfxMngr)
grfx.r = c
component, err := grfx.engine.LoadFile("file3.qml")
if err != nil {
panic(err)
}
c.Object = component.Create(nil)
obj := c.Object.Interface().(*GoQmlRect)
obj.R = c
obj.Test = "what"
c.Set("parent", grfx.window.Root())
}
示例15: LoadConfig
// LoadConfig is needed as a backdoor to factory not being inititalized
func LoadConfig(file string) types.JGameObject {
defer debug.Trace().UnTrace()
data, err := support.OpenFile(file)
if err != nil {
debug.Fatal("Failed to open Config file: " + file)
}
holder, err := support.ReadData(data)
if err != nil {
debug.Fatal("Failed to read in Config file: " + file)
return nil
}
goc := types.JGoc{}
serialization.SerializeInPlace(&goc, holder)
return &goc
}