Use pointer to object instead of struct for embedding.
This commit is contained in:
parent
c9f8027f81
commit
5fc2dd92dd
3 changed files with 14 additions and 12 deletions
|
@ -5,7 +5,13 @@ import (
|
|||
)
|
||||
|
||||
type Player struct {
|
||||
gx.Object
|
||||
*gx.Object
|
||||
}
|
||||
|
||||
func NewPlayer() *Player {
|
||||
return &Player{
|
||||
Object: &gx.Object{},
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -15,6 +21,6 @@ func main() {
|
|||
Height: 320,
|
||||
})
|
||||
|
||||
e.Add(0, Player{})
|
||||
e.Add(0, NewPlayer())
|
||||
e.Run()
|
||||
}
|
||||
|
|
|
@ -6,11 +6,6 @@ type Behaver interface {
|
|||
GetObject() *Object
|
||||
}
|
||||
|
||||
// The object that is drawn by sprite
|
||||
/// based on the transform.
|
||||
type Sprite struct {
|
||||
}
|
||||
|
||||
// The object type represents
|
||||
// basic information for interaction
|
||||
// with the engine.
|
||||
|
@ -19,9 +14,9 @@ type Object struct {
|
|||
}
|
||||
|
||||
// The functions that
|
||||
func (o Object) Start(e *Engine) {}
|
||||
func (o Object) Update(e *Engine) {}
|
||||
func (o Object) GetObject() *Object {
|
||||
return &o
|
||||
func (o *Object) Start(e *Engine) {}
|
||||
func (o *Object) Update(e *Engine) {}
|
||||
func (o *Object) GetObject() *Object {
|
||||
return o
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
package gx
|
||||
|
||||
|
||||
type Sprite struct {
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue