i often stumble over a problem concerning my animation sequences:
normally each sprite has 1..n animation objects for controling all bitmap-based animation sequences. therefore the relation
of both classes is single wayed
sprite ---has--> animation
but sometimes i need to know the exact moment when a sequence has just ended. e.g. the sprite exploded so after that it can be removed.
i only see two solutions:
- a bidirectional relationship so that every animation can consult its sprite reference
(which can be somewhat tricky cause all other animations which do *not* require to notify the sprite do not know that they shoul not do so ... this would require more additional workarounds)
- i could permanently ask:
are you finished ...are you finished ...are you finished ...are you finished ...are you finished ...are you finished ...

btw:
in general if you need back references for very special purposes, dou you rely on using normal references correct or do you write interfaces just for this purpose (or use observer or whatever)