This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-05-04 12:58:22

titaniumbones
Scratcher
Registered: 2010-04-20
Posts: 8

which sprite is on top when two or more occupy the same place?

How can I predict which sprite will beo n top when two sprites occupy the same region of the screen?  Obviously this is aesthetically importnt but rightn ow this is importnt for me bd I want to send a message if a crosshair is clicked, but the crosshair is always behind the target sprite!  My project is currently here if that helps:
http://scratch.mit.edu/projects/clintonhackers/1027449
though it's going to change quickly i think.

thanks much!
matt

Offline

 

#2 2010-05-04 17:33:19

Ratty1967UK
Scratcher
Registered: 2007-05-16
Posts: 88

Re: which sprite is on top when two or more occupy the same place?

the easy answer is to use the <go to front> block on your cross-hair

I use a slightly more flexible algorithm to enable layers in my projects - using a global variable for zpos iterated from 10 down to 1 and broadcast all sprites to set their zposition - if zpos matches the proposed zposition of the sprite then it does a <go to front>

Offline

 

#3 2010-05-07 17:58:48

titaniumbones
Scratcher
Registered: 2010-04-20
Posts: 8

Re: which sprite is on top when two or more occupy the same place?

That's great, thanks so much fo the help!  i like the zpos solution as well, if we do something more complex I'll use a version of it. 
thanks again,
mat

Offline

 

Board footer