@Kyatric, @Yann: Thanks immensely for so patiently and promptly sharing your knowledge! You've helped to clarify a number of issues concerning object instances.
So what have I learnt? (Please tell me if I've got any of these conclusions wrong!):
In order for an event that's dependent on a system condition
to affect only a particular object instance that's chosen in advance by the coder
at build time, we need to have some means of picking that instance (other conditions can be filtered for particular instances as explained in the Manual). Such system conditions can occur when a game is replayed, or a new level is reached, or a certain time has passed, and we then need to reset the state of a particular instance (e.g. the centre cat in our demo).
Construct 2 offers no way of naming individual object instances at build time (unlike OO languages). (It might be thought that UIDs could be directly used for this purpose, but their value is not known till runtime, so can't be used when building). There are workarounds to ensure that such a system condition will affect only a particular instance:
- One workaround is to set up an event to save the (runtime) value of an instance UID in a global variable, and then use that variable to pick that particular instance.
- Another workaround is to add to an object type an instance variable that can be given a different value for each instance, and then be used to pick a particular instance. This is what we all seem to be agreed on, since each of our demos has the same 'Reset' event:
Again, please tell me if this doesn't make sense - or if there's some simpler way of doing this!Velojet2012-01-11 08:38:17