[Newbies] Question about Etoys Custome Events and Triggering Objects

Bert Freudenberg bert at freudenbergs.de
Tue Sep 4 01:11:49 UTC 2018

On Mon, 3 Sep 2018 at 17:39, Jeremy Landry <hakyoku at gmail.com> wrote:

> This question pertains to Etoys 5.
> I'm trying to set up communication between two objects using event
> triggers, but cannot seem to understand what I'm doing wrong.
> Here is the project:
> https://drive.google.com/open?id=1hQ9VqRkQu4VeH75dxV0inwL4HXGMDZFg
> Here is the description of desired effect:
> The playfield tells all Enemy objects (just one in this case) to
> 'bounceAround'. Then following that, tells all BGTile objects to 'beSolid'.
> If the Enemy object overlaps any BGTile object with it's variable of
> 'isSolid' set to True, that BGTile object triggers an event the Enemy
> object responds to.  The problem is that the trigger isn't seen by the
> Enemy object as having come from BGTile but from the entire playfield!
> I set up a variable within Enemy to figure out why setting Enemy's Bottom
> to Enemy's Triggering Object's Top would send the Enemy completely off the
> screen.
> Is this because the originating script that is ticking is the Playfield's
> script?  If so, how should I set this up to create a situation where
> sibling objects can find specifically which ones actually collided if the
> Triggering Object will always be the originating ticking script?
> Thanks for any help and I hope this makes sense.  I left the offending
> scripts open along with the Enemy viewer flap so that the triggering object
> variable is seen.

This kind of general object-object interaction is hard in Etoys.

We generally try to design around it. For example, in Pac-Man, the obvious
approach would be to move the player, check if it collided with a dot, then
delete that dot. This doesn't work because it is not easy to check which
dot it collided with. Instead, we have all the dots ticking to check if
they collided with the player, and if so delete themselves and increase the
global score.

Maybe you can design your game in a similar way?

- Bert -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/beginners/attachments/20180903/ee8772cc/attachment.html>

More information about the Beginners mailing list