Design Question: Delegation vs. callbacks
Henning Hasemann
hhasemann at web.de
Sun Jun 17 01:58:24 PDT 2007
> Normally, I'd expect thing (or widget) to be a base class for many
> graphics objects.
Ok, Ill give some more detail here:
My project is an engine for classical 2D adventures (like the old
LucasArts ones).
A thing is everything the player can interact with. I.e it might be
another character, or something to pick up or to push, ...
A thing needs an area to be able to receive mouse clicks, but I need
areas in other places, too (for example in 'regions' when I want to
trigger events as soon as the character stands at a certain place)
> If you want a coherent architecture that doesn't confuse the user,
> I'd recommend avoiding differing types of functionality with the same
> function name. Maybe it's best to rename one or both of your isIn
> functions?
Are you talking about something like isInRelative() and isInAbsolute()?
Sounds like a good idea for the delegate approach.
> If position is defined to be the upper left corner of a bounding
> box (or some similar definition), one of two things should result:
> a. The position to change if a component has been changed. The
> object has changed, so its properties changed. The user must live
> with it. b. The containing object forces everything inside it to
> conform to its dimensions. Drawing a circle that goes outside of a
> window shouldn't leave a mark on the desktop...
A thing can also define its alignment relative to its position.
For example most things have their position ad middle-bottom (center of
feet) which hos some advantages when finding out the z-order of objects.
Thanks so far for your answer. It already helped me much to see the
thing a bit clearer.
--
GPG Public Key:
http://keyserver.ganneff.de:11371/pks/lookup?op=get&search=0xDDD6D36D41911851
Fingerprint: 344F 4072 F038 BB9E B35D E6AB DDD6 D36D 4191 1851
More information about the Digitalmars-d-learn
mailing list