We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define type for "any Sprite instance", e.g.
type ISprite interface { IEventSink Animate(name string) Ask(msg interface{}) BounceOffEdge() Bounds() *math32.RotatedRect ChangeEffect(kind EffectKind, delta float64) ChangeHeading(dir float64) ChangePenColor(delta float64) ChangePenHue(delta float64) ChangePenShade(delta float64) ChangePenSize(delta float64) ChangeSize(delta float64) ChangeXYpos(dx float64, dy float64) ChangeXpos(dx float64) ChangeYpos(dy float64) ClearGraphEffects() CostumeHeight() float64 CostumeIndex() int CostumeName() string CostumeWidth() float64 Destroy() Die() DistanceTo(obj interface{}) float64 Glide__0(x float64, y float64, secs float64) Glide__1(obj interface{}, secs float64) GoBackLayers(n int) Goto(obj interface{}) GotoBack() GotoFront() Heading() float64 Hide() HideVar(name string) InitFrom(src *Sprite) IsCloned() bool Move__0(step float64) Move__1(step int) NextCostume() OnCloned__0(onCloned func(data interface{})) OnCloned__1(onCloned func()) OnMoving__0(onMoving func(mi *MovingInfo)) OnMoving__1(onMoving func()) OnTouched__0(onTouched func(obj *Sprite)) OnTouched__1(onTouched func()) OnTouched__2(name string, onTouched func(obj *Sprite)) OnTouched__3(name string, onTouched func()) OnTouched__4(names []string, onTouched func(obj *Sprite)) OnTouched__5(names []string, onTouched func()) OnTurning__0(onTurning func(ti *TurningInfo)) OnTurning__1(onTurning func()) Parent() *Game PenDown() PenUp() PrevCostume() Quote__0(message string) Quote__1(message string, secs float64) Quote__2(message string, description string, secs ...float64) Say(msg interface{}, secs ...float64) SetCostume(costume interface{}) SetDying() SetEffect(kind EffectKind, val float64) SetHeading(dir float64) SetPenColor(color color.RGBA) SetPenHue(hue float64) SetPenShade(shade float64) SetPenSize(size float64) SetRotationStyle(style RotationStyle) SetSize(size float64) SetXYpos(x float64, y float64) SetXpos(x float64) SetYpos(y float64) Show() ShowVar(name string) Size() float64 Stamp() Step__0(step float64) Step__1(step int) Step__2(step float64, animname string) Think(msg interface{}, secs ...float64) Touching(obj interface{}) bool TouchingColor(color color.RGBA) bool Turn(val interface{}) TurnTo(obj interface{}) Visible() bool Xpos() float64 Ypos() float64 } type IEventSink interface { OnAnyKey(onKey func(key Key)) OnBackdrop__0(onBackdrop func(name string)) OnBackdrop__1(name string, onBackdrop func()) OnClick(onClick func()) OnKey__0(key Key, onKey func()) OnKey__1(keys []Key, onKey func(Key)) OnKey__2(keys []Key, onKey func()) OnMsg__0(onMsg func(msg string, data interface{})) OnMsg__1(msg string, onMsg func()) OnStart(onStart func()) Stop(kind StopKind) }
var ( enemies []ISprite ) func addEnemy(s ISprite) { enemies = append(enemies, s) } func removeEnemy(s ISprite) { for i, e := range enemies { if e == s { enemies = append(enemies[:i], enemies[i+1:]...) break } } } func countEnemy() int { return len(enemies) } func isAttacked(from ISprite, to ISprite) bool { if int(from.heading()) == Right { return to.xpos() > from.xpos() && to.xpos() < from.xpos()+50 } if int(from.heading()) == Left { return to.xpos() < from.xpos() && to.xpos() > from.xpos()-50 } return false } func findEnemyAttacked(from ISprite) ISprite { for _, e := range enemies { if isAttacked(from, e) { return e } } return nil }
The text was updated successfully, but these errors were encountered:
Related: goplus/spx#316
Sorry, something went wrong.
OnTouched
nighca
Successfully merging a pull request may close this issue.
Define type for "any Sprite instance", e.g.
Usage
The text was updated successfully, but these errors were encountered: