Discuss Scratch

PkmnQ
Scratcher
1000+ posts

Touching Any Sprite Boolean

IronBit_Studios wrote:

Basically, what my idea is is that there should be an “Touching any sprite” Boolean, because for some projects that involve just touching a sprite in general (Like a scanner that checks for sprites), it takes a long time to write “if touching Sprite2 or if touching Sprite3, etc.” I think it would look like this:
credit to stickfiregames
<touching [any sprite v] ?>
There should also be a reporter called
(sprites touching :: sensing)
I'm noticing a lot of people are asking the same thing-

Alberknyis wrote:

Explain where an “any sprite touched” block could be used.
Well,

IronBit_Studios wrote:

Projects that involve sprite-scanning, for some projects that involve just touching a sprite in general (Like a scanner that checks for sprites), it takes a long time to write “if touching Sprite2 or if touching Sprite3, etc.”. It would be fairly easy to implement, and otherwise…
<<touching [ v] ?> or <<touching [ v] ?> or <<touching [ v] ?> or <<touching [ v] ?> or <<touching [ v] ?> or <<touching [ v] ?> or <<touching [ v] ?> or <<touching [ v] ?> or < > > > >> > >  > > 
CURRENT SUPPORTERS (46 And Counting)
IronBit_Studios(obviously)
stickfiregames
CosmicSans
CatsUnited
LionsStair
NolanAwesome
44701
scratchrainbow
Silphaer
peterules54
ev3commander
Alberknyis (90%)
Cyoce
theonlygusti
Starbolt1
TheHockeyist
mundofinkyenglish
Tommy100
m801234
JoeyTheChicken
scrooge200
Penguin9090_new
thelucariokid
scratch_inno
Tymewalk
nether_before
19f8361
pokejofe
HSL2014
Pot-Of-Gold
marilynjosiahbojo
CGRises
Cream_E_Cookie
Samanyolu
Unlicht
Scratcher1002
scratchinghead
wizard192
gamebeater187
BookOwl
Ninchanko
Botchko_Otkho
Leadrien2366
DrEthan
JonathanSchaffer
Inreal49
Non-supporters
ShadowFlareX
Econinja
Blank1234

0.999… support
Maybe it can be its own block:
<touching any sprite ? :: sensing>
and another thing:
<touching any sprite except for [not the sprite you want v] ? :: sensing>
JonathanSchaffer
Scratcher
1000+ posts

Touching Any Sprite Boolean

Econinja wrote:

The workaround isn't very tedious. By saying that, we should have a block that records dates when you could do this:
(join (current [date v]  (join [/] (join (current [month v] (join [/] (current [year v] :: operator) :: operator) :: operator)  :: operator)
Excuse my messy scratchblocks syntax thing. You get the idea
No support.
(join (current [date v])  (join [/] (join (current [month v])(join [/] (current [year v] :: operator) :: operator) :: operator)  :: operator)
fixed it for you.

Last edited by JonathanSchaffer (Jan. 29, 2017 13:53:05)

jromagnoli
Scratcher
1000+ posts

Touching Any Sprite Boolean

PkmnQ wrote:

-snip-

0.999… support
Maybe it can be its own block:
<touching any sprite ? :: sensing>
and another thing:
<touching any sprite except for [not the sprite you want v] ? :: sensing>
Please don't quote the whole FP, it just clutters the place with long posts. Thanks!
TailsFanV51
Scratcher
1000+ posts

Touching Any Sprite Boolean

can be the biggest workaround ever
Imagine yer have 6 sprites
<<touching [ v] ?> or <<touching [ v] ?> or <<touching [ v] ?> or <<touching [ v] ?> or <touching [ v] ?>>>>>

Last edited by TailsFanV51 (Feb. 5, 2017 06:24:51)

WolfCat67
Scratcher
1000+ posts

Touching Any Sprite Boolean

I can see how this would be used. Even if you didn't want it to be every sprite, and just MOST of them, you could just do this:
if <<touching [any sprite v]?> and <<not <touching [Sprite18 v]?>> and <not <touching [Sprite19 v]?>>>> then
broadcast [Touching any sprite but Sprite18 and Sprite19! v]
end
_nix
Scratcher
1000+ posts

Touching Any Sprite Boolean

I'm obviously not going to go through all the pages of this topic to see if anybody's suggested this, but it's possible that the “touching” block will be able to take arbitrary inputs (that is, reporters) in Scratch 3.0. In that case you could do something like this:

when I start as a clone // this is a particle!
forever
move around using particle physics
delete (all v) of [Sprite List v]
add [Normal Ground] to [Sprite List v] // a floor/wall sprite
add [Enemy Ground] to [Sprite List v] // another floor/wall sprite
add [Enemy Class] to [Sprite List v] // has clones that might move around
add [Player Class] to [Sprite List v] // has clones that are controlled by player(s)
detect touching
if <(Touching?) = [1]> then
delete this clone // oh no, we died
end
end

define detect touching
set [Touching? v] to [0] // 0 by default, if we're not touching any of the sprites this won't be set to 1
set [parse v] to [1]
repeat (length of [Sprite List v]) // for every item, if we're touching that sprite, touching should become true
if <touching (item (parse) of [Sprite List v]) ?> then // the important part!
set [Touching? v] to [1]
end
change [parse v] by (1)

define move around using particle physics
move (10) steps // just for the example

This project implements a simple particle that will disappear when it touches any sprite or clone from the “Sprite List” list. Plus, it's pretty easy to customize – for example, you could make it so that you might don't add the player to the sprite list if the player has an invisibility power-up.. and you wouldn't be able to do that using “touching (any sprite)”.
redgreenandblue
Scratcher
100+ posts

Touching Any Sprite Boolean

Honestly I would like a
<touching [backdrop v] ?>
It would do the same thing as a
<not <touching [any sprite v] ?>>
FANTASTICMRF0X
Scratcher
2 posts

Touching Any Sprite Boolean

_nix wrote:

I'm obviously not going to go through all the pages of this topic to see if anybody's suggested this, but it's possible that the “touching” block will be able to take arbitrary inputs (that is, reporters) in Scratch 3.0. In that case you could do something like this:

when I start as a clone // this is a particle!
forever
move around using particle physics
delete (all v) of [Sprite List v]
add [Normal Ground] to [Sprite List v] // a floor/wall sprite
add [Enemy Ground] to [Sprite List v] // another floor/wall sprite
add [Enemy Class] to [Sprite List v] // has clones that might move around
add [Player Class] to [Sprite List v] // has clones that are controlled by player(s)
detect touching
if <(Touching?) = [1]> then
delete this clone // oh no, we died
end
end

define detect touching
set [Touching? v] to [0] // 0 by default, if we're not touching any of the sprites this won't be set to 1
set [parse v] to [1]
repeat (length of [Sprite List v]) // for every item, if we're touching that sprite, touching should become true
if <touching (item (parse) of [Sprite List v]) ?> then // the important part!
set [Touching? v] to [1]
end
change [parse v] by (1)

define move around using particle physics
move (10) steps // just for the example

This project implements a simple particle that will disappear when it touches any sprite or clone from the “Sprite List” list. Plus, it's pretty easy to customize – for example, you could make it so that you might don't add the player to the sprite list if the player has an invisibility power-up.. and you wouldn't be able to do that using “touching (any sprite)”.

If this is true, how do you make the sprite react to touching clones that are added to the list? I tried doing this, but it did not work in my project

Last edited by FANTASTICMRF0X (May 3, 2017 19:24:46)

mdillge2
New Scratcher
1 post

Touching Any Sprite Boolean

if we could just choose multiple objects in the touching pull down menu that would do it, no? Cause this problem has me totally stuck right now. I refuse to believe the long string or or or is the way to go. It would work, put so awkward, that can't be the way right? Can lists be used?
aidenawesome
Scratcher
18 posts

Touching Any Sprite Boolean

support!
it would also be helpful to have
(number of sprites i'm touching::sensing)
MrScratchy09
Scratcher
100+ posts

Touching Any Sprite Boolean

Support! This would be so helpful
TopicBumper
New Scratcher
100+ posts

Touching Any Sprite Boolean

Bump.
Rendangbike2
Scratcher
1000+ posts

Touching Any Sprite Boolean

Support! If there is 10 walls that if the sprite is touching, it would do the same thing and this block would be really useful
dertermenter
Scratcher
1000+ posts

Touching Any Sprite Boolean

Support, the workaround is to long and sometimes I need this for games
BanMeOS
Scratcher
500+ posts

Touching Any Sprite Boolean

TopicBumper wrote:

Bump.
BanMeOS
Scratcher
500+ posts

Touching Any Sprite Boolean

BanMeOS wrote:

TopicBumper wrote:

Bump.
<touching [all sprites v] ?>

Last edited by BanMeOS (Sept. 11, 2021 14:02:21)

1080GBA
Scratcher
500+ posts

Touching Any Sprite Boolean

redgreenandblue wrote:

Honestly I would like a
<touching [backdrop v] ?>
It would do the same thing as a
<not <touching [any sprite v] ?>>
You could just partially touch a sprite which breaks your workaround
(You can touch a both at the same time but the workaround only reports true when its only touching background)
blablablahello
Scratcher
1000+ posts

Touching Any Sprite Boolean

Support, although you could workaround by using a list and loop checking each sprite in the list, however, that would be extremely annoying, and would not work if there is unkown amounts of sprites (like clones, for example)
Kaimakiii
Scratcher
10 posts

Touching Any Sprite Boolean

Eh. Perhaps, but I don't really think a new block is necessary. What about
<touching [ any sprite] ?>
broadcast [ I guess I agree?]

Last edited by Kaimakiii (May 26, 2022 12:14:43)

Kaimakiii
Scratcher
10 posts

Touching Any Sprite Boolean

Forgive that reporter, I don't know how to make it drop-down

Powered by DjangoBB