touchesA: (Does anyone think it works?)

Rik Fischer Smoody riks at smOO.com
Mon Jan 28 21:37:43 UTC 2002


A student was playing with scripting and used the
touchesA:
test. I tried it myself.
Neither of us saw what we expected.
I looked at the method.
---------------------
touchesA: aPrototypicalPlayer

	| envelope myBounds trueNeighbor trueGoal trueSelf |

	aPrototypicalPlayer ifNil: [^false].
	envelope _ costume owner ifNil: [^false].
	myBounds _ costume bounds.
	trueSelf _ costume renderedMorph.
	trueGoal _ aPrototypicalPlayer costume renderedMorph.
	envelope submorphs do: [ :each |
		trueNeighbor _ each renderedMorph.
		(trueNeighbor == trueGoal or: [trueNeighbor == trueSelf]) ifFalse: [
			(myBounds intersects: each bounds) ifTrue: [
				(trueGoal appearsToBeSameCostumeAs: trueNeighbor) ifTrue: [ ^true].
			].
		].
	].
	^false
----------------------
I put in a halt and stepped through and do not see how it could possibly return true when we expected it to.
We tried resetting our expectations: maybe it is supposed to mean 
"Does it touch some (Star), but not the one we pasted into the script?"
After poking at that hypothesis, I'm starting to agree with my student's original
hypothesis:
"This does not work"

I seldom use scripting, so
I'm open to a forehead slapper here if we just missed the point.

We have several examples of Morphs "noticing" each other by proximity
by ohter means.  One of them can serve as a work-around.

Does anyone use this successfully?
If so, please tell us how or send us a wee example project or morph.

Thanx,
Rik

Rik Fischer SmOOdy     riks at smoo.com
	smOOdynamics    -     Systems Made Outa Objects
		503-249-8300 ph/fx
	2400 NE 25th, Suite 800
	Portland, OR 97212
---
Bush, Cheney, Ashcroft, Rumsfeld, Lay, ...
the terrorists are winning.





More information about the Squeak-dev mailing list