Share this Page URL


CONTROLLING BITMAPS 334 So, if users click the upper-left corner of the distorted sprite, the function returns point (0,0). Here is an on mouseUp handler that uses the mapStageToMember function to calculate where users clicked: on mouseUp me p = mapStageToMember(sprite 1, the clickLoc) x = 1+p.locH/20 y = 1+p.locV/20 put "Row:"&&x&&"Column:"&&y end The flip side of the mapStageToMember function is the mapMemberToStage function. You can use it to find any Stage location based on a location in the member. Here is a handler that returns the Stage location when given a space on the chessboard: on getPos me, x, y p = point(x*20-10,y*20-10) return mapMemberToStage(sprite 1, p) end To position the queen as seen previously on Figure 18.5, you can use this behavior. It assumes that the board is in Sprite channel 1. on beginSprite me p = getPos(sprite 1, 4, 5) sprite(me.spriteNum).loc = p end Mapping sprites in this way enables you to distort one sprite and then position other sprites relative to this distortion. It can be used along with the cube example to place an object on the face of a