Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do you change the size of a sprite based on mouse distance? (The closer the bigger)
- Creeper_Kid_TNT
-
Scratcher
20 posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
More Specific: I have 3 sprites and all are moving, i want to take the distance between the furthest sprite and somehow change both the movement speed and size apposing to that distance, making it so that the closer the sprites, the bigger the size. (mouse is a temporary replacement) if needed the Min/Max size for the sprite im using is 15/1636, the only problem i have is the size and speed issue
Last edited by Creeper_Kid_TNT (Jan. 5, 2024 14:24:04)
- YourAverageUser22
-
Scratcher
93 posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
I cant find a working solution without the sprite size going to extremes. Thanks.I've honestly tried my best to find a solution but can't…
Last edited by YourAverageUser22 (Jan. 4, 2024 15:25:46)
- DogeMeowy
-
Scratcher
100+ posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
I think I found it idk how to show it on forums but I can share the project if you want you can use it without credit if I share how
- DD-8861
-
Scratcher
100+ posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
Are you looking for something like this?
when green flag clicked
forever
set size to ((100) - (distance to [mouse pointer v])) %
end
- alebro6DW
-
Scratcher
100+ posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
when idk :: looks :: hat
forever
set size to ((distance to [mouse-pointer v]) * (0.1)) %
end
- WCBurns
-
Scratcher
20 posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
I cant find a solution for this.This is the opposite of what you want if the sprite is at 0-0. Maybe you could adjust it?:
when green flag clicked
set size to (100) %
forever
set size to (([abs v] of (x position)) + ([abs v] of (y position))) %
end
- DogeMeowy
-
Scratcher
100+ posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
when idk :: looks :: hat[/q
forever
set size to ((distance to [mouse-pointer v]) * (0.1)) %
endwhen idk :: looks :: hat
forever
set size to ((distance to [mouse-pointer v]) * (0.1)) %
endwhen green flag clicked
forever
[quote=alebro6DW][scratchblocks]
when idk :: looks :: hat
forever
set size to ((distance to [mouse-pointer v]) * (0.1)) %
end
[/scratchblocks][/quote]
It worksi think
- Creeper_Kid_TNT
-
Scratcher
20 posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
I cant find a solution for this.This is the opposite of what you want if the sprite is at 0-0. Maybe you could adjust it?:when green flag clicked
set size to (100) %
forever
set size to (([abs v] of (x position)) + ([abs v] of (y position))) %
end
thats kinda what i want but the reason why i used mouse pointer was because i was gonna replace it with a moving sprite, i should probably have specified that, but it works.
Last edited by Creeper_Kid_TNT (Jan. 5, 2024 14:15:11)
- Jacko_Playsgames
-
Scratcher
24 posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
Are you looking for something like this?im also using this, but one question, how do you change the minimum size? mine is stuck at 7when green flag clicked
forever
set size to ((100) - (distance to [mouse pointer v])) %
end
- awesome-llama
-
Scratcher
1000+ posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
im also using this, but one question, how do you change the minimum size? mine is stuck at 7Switch to a larger costume. The sprite size limit depends on the costume.
switch costume to [large costume v]
set size to (1) %
switch costume to [desired costume v]
- Matthobro120
-
Scratcher
48 posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
How about this?
when green flag clickedthis is also for @Jacko_Playsgames since the muliplier also effects minimum size
forever
set size to ((100) - ((distance to [mouse pointer v]) * (0.8))) % // 100 makes it work how you want, 0.8(changable) is the effect multiplier.
end
- The_Cool_Test_Alt
-
Scratcher
92 posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
You could make it a reciprocal relationship as shown below:
add [\[name of the first sprite\]] to [sprites v]
add [\[name of the second sprite\]] to [sprites v]
add [\[name of the third sprite\]] to [sprites v]
forever
go to [mouse pointer v]
set [sprite number v] to [0]
set [distance v] to [0]
repeat (3)
change [sprite number v] by (1)
if <(distance to (item (sprite number) of [list v] )) > (distance :: variables)> then
set [distance v] to (distance to (item (sprite number) of [list v])
end
end
set size to ([\[your default size\]] / ((distance :: variables) * [\[your default distance\]])
set [movement speed v] to ([\[your default speed\]] / ((distance :: variables) * [\[your default distance\]])
- Jacko_Playsgames
-
Scratcher
24 posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
How about this?thank you so muchwhen green flag clickedthis is also for @Jacko_Playsgames since the muliplier also effects minimum size
forever
set size to ((100) - ((distance to [mouse pointer v]) * (0.8))) % // 100 makes it work how you want, 0.8(changable) is the effect multiplier.
end

- Discussion Forums
- » Help with Scripts
-
» How do you change the size of a sprite based on mouse distance? (The closer the bigger)









