Is is possible to customize the areas of a sprite to
get a different response depending on where you
click without having to create a different sprite for
each ?
i.e.
Something like this:
Sprite A
When Click on x=200 to 250 & y=180 to 200
Do action A
Sprite A (again)
When Click on x=100 to 200 & y=150 to 180
Do action A
You can get the mouse pos x relative to the top-left corner of sprite by subtracting its left from the mouse x. You can do the same for mouse pos y, you subtract the sprite's top from the mouse y
[scratchblocks]
define run(a) when x=(200) to (250) and y=(180) to (200)
forever
if << mouse down >and<<<(x position)>(200)> and < (x position)<(250)>>and<< (y position)>(180)> and< (y position)<(200) >>>> then
set(time v) to(0)
repeat until <not< mouse down >>
change (time) by((1)/(30))
if<(time)>(0.2)>then
stop(this script v)
end
end
run(a)
end
[/scratchblocks]
The standard way to do things like this is sprite nesting. See page 10 of the manual. You can make a combined sprite with as many parts as you want. They all move as a unit, but receive clicks (or collisions, etc.) independently. You can clone the whole thing all at once.