Convenience function to addd and remove actors to or from systems.

This commit is contained in:
Marvin Blum
2016-05-06 17:30:43 +02:00
parent ac3d293763
commit 51d61ba605
3 changed files with 48 additions and 11 deletions

View File

@@ -101,20 +101,13 @@ func (s *SpriteRenderer) Add(actor interface{}) bool {
// Removes sprite from renderer.
func (s *SpriteRenderer) Remove(actor interface{}) bool {
sprite, ok := actor.(Sprite)
sprite, ok := actor.(*Sprite)
if !ok {
return false
}
for i, sp := range s.sprites {
if sp == sprite {
s.sprites = append(s.sprites[:i], s.sprites[i+1:]...)
return true
}
}
return false
return s.RemoveById(sprite.Actor.GetId())
}
// Removes sprite from renderer by ID.