Class:touched question

I am looking for an example of how the touched method is used in regards to a class. Does anyone have a simple example they can share?

Thanks.

The touched() function of a class has to be called directly. I find it handy if you need to compare the coordinates of the touch against the object. Often, I end up using this function as just “was I touched?” and returning true/false.

So if I have a class of objects, in the draw function I iterate through all the objects calling the objects:touched(touch) method to determine which one was touched? Or is there a way for it to return directly the one touched?

Looping through with plain old if is how I handle it, but you could probably do a for loop and return a neat collection of every object that was touched.

OK - Thanks, Mark.

Or reverse it and have a table of things on the screen with thier positions and a pointer to the classes/objects

I don’t think either way is better, it’s six one way and half a dozen the other

Well, I’m sure I didn’t do it right, but here is a first stab at the basics of a game. Only the board is developed and rudimentary moving. Still need to add the fun stuff (enemies, bazaars, scoring, and of couse the final attack on the tower.)
I’m really slow with this stuff, as I often do it quick and dirty, then regret it later because of the messy code, and redo it several more times. Still trying to get my head around classes.

jlslate.posterous.com/BlackTower

Jim