Skip to content

Commit

Permalink
Remove SpriteImpl from interface Sprite
Browse files Browse the repository at this point in the history
  • Loading branch information
qlli committed Oct 14, 2024
1 parent ab75a75 commit 7e73678
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion event.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (p *eventSinkMgr) doWhenTouched(this threadObj, obj *SpriteImpl) {
if debugEvent {
log.Println("==> onTouched", nameOf(this), obj.name)
}
ev.sink.(func(*SpriteImpl))(obj)
ev.sink.(func(interface{}))(obj)
})
}

Expand Down
39 changes: 21 additions & 18 deletions sprite.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ type Sprite interface {
Heading() float64
Hide()
HideVar(name string)
InitFrom(src *SpriteImpl)
IsCloned() bool
Move__0(step float64)
Move__1(step int)
Expand All @@ -107,11 +106,11 @@ type Sprite interface {
OnCloned__1(onCloned func())
OnMoving__0(onMoving func(mi *MovingInfo))
OnMoving__1(onMoving func())
OnTouched__0(onTouched func(obj *SpriteImpl))
OnTouched__0(onTouched func(data interface{}))
OnTouched__1(onTouched func())
OnTouched__2(name string, onTouched func(obj *SpriteImpl))
OnTouched__2(name string, onTouched func(data interface{}))
OnTouched__3(name string, onTouched func())
OnTouched__4(names []string, onTouched func(obj *SpriteImpl))
OnTouched__4(names []string, onTouched func(data interface{}))
OnTouched__5(names []string, onTouched func())
OnTurning__0(onTurning func(ti *TurningInfo))
OnTurning__1(onTurning func())
Expand Down Expand Up @@ -460,7 +459,7 @@ func (p *SpriteImpl) fireTouched(obj *SpriteImpl) {
}
}

func (p *SpriteImpl) OnTouched__0(onTouched func(obj *SpriteImpl)) {
func (p *SpriteImpl) OnTouched__0(onTouched func(interface{})) {
p.hasOnTouched = true
p.allWhenTouched = &eventSink{
prev: p.allWhenTouched,
Expand All @@ -473,39 +472,43 @@ func (p *SpriteImpl) OnTouched__0(onTouched func(obj *SpriteImpl)) {
}

func (p *SpriteImpl) OnTouched__1(onTouched func()) {
p.OnTouched__0(func(*SpriteImpl) {
p.OnTouched__0(func(data interface{}) {
onTouched()
})
}

func (p *SpriteImpl) OnTouched__2(name string, onTouched func(obj *SpriteImpl)) {
p.OnTouched__0(func(obj *SpriteImpl) {
if obj.name == name {
func (p *SpriteImpl) OnTouched__2(name string, onTouched func(interface{})) {
p.OnTouched__0(func(data interface{}) {
obj := data.(*SpriteImpl)
if obj != nil && obj.name == name {
onTouched(obj)
}
})
}

func (p *SpriteImpl) OnTouched__3(name string, onTouched func()) {
p.OnTouched__2(name, func(*SpriteImpl) {
p.OnTouched__2(name, func(interface{}) {
onTouched()
})
}

func (p *SpriteImpl) OnTouched__4(names []string, onTouched func(obj *SpriteImpl)) {
p.OnTouched__0(func(obj *SpriteImpl) {
name := obj.name
for _, v := range names {
if v == name {
onTouched(obj)
return
func (p *SpriteImpl) OnTouched__4(names []string, onTouched func(interface{})) {
p.OnTouched__0(func(data interface{}) {
obj := data.(*SpriteImpl)
if obj != nil {
name := obj.name
for _, v := range names {
if v == name {
onTouched(obj)
return
}
}
}
})
}

func (p *SpriteImpl) OnTouched__5(names []string, onTouched func()) {
p.OnTouched__4(names, func(*SpriteImpl) {
p.OnTouched__4(names, func(interface{}) {
onTouched()
})
}
Expand Down

0 comments on commit 7e73678

Please sign in to comment.