Q: Does morphic 'touchesA' work?

Bob Arning arning at charm.net
Sun Dec 15 19:22:35 UTC 2002


On Sun, 15 Dec 2002 15:51:37 +0000 Dave Brown <dave at wilbert.demon.co.uk> wrote:
>I'm fairly new to squeak and I am having trouble getting 'touchesA' to 
>work.
>
>Does it work?
>
>I am creating a morphic game for my kids ( with their help ) and want 
>to get a torpedo to hit a battleship. However when the torpedo goes 
>under / over the ship the yes part of the test is not triggered however 
>the no part seems to get triggered as soon as you set the script 
>running.

Dave,

It's a little counter-intuitive - "touchesA" tests whether there is an intersection with something that looks like the argument, but not with the argument itself. This was done for an epidemic eToy where infected atoms said something like: "atom lookLike RedDot". Then we could ask whether we were touching a RedDot (i.e. something that looked like RedDot, which was a prototype that never actually entered into the arena).

So, what will work is this:

- draw your battleship
- name it BattleShip
- move it out of the playing area (it will just be a prototype for actual battleships)
- make as many copies as you like of the prototype using the green halo handle (these will get names like "BattleShip1" etc).
- the test in torpedo says "Torpedo touchesA BattleShip" and will activate the Yes part whenever a torpedo intersects BattleShip1, BattleShip2, etc. It will _not_ activate if the torpedo should encounter the ptototype.

Or, as Karl says, there is also an "overlaps" test in 3.4.

Cheers,
Bob



More information about the Squeak-dev mailing list