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
-
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
-
93 posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
I've honestly tried my best to find a solution but can't… I cant find a working solution without the sprite size going to extremes. Thanks.
Last edited by YourAverageUser22 (Jan. 4, 2024 15:25:46)
- DogeMeowy
-
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
-
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
-
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
-
20 posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
This is the opposite of what you want if the sprite is at 0-0. Maybe you could adjust it?: I cant find a solution for this.
when green flag clicked
set size to (100) %
forever
set size to (([abs v] of (x position)) + ([abs v] of (y position))) %
end
- DogeMeowy
-
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
-
20 posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
This is the opposite of what you want if the sprite is at 0-0. Maybe you could adjust it?: I cant find a solution for this.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
-
24 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 7 Are you looking for something like this?when green flag clicked
forever
set size to ((100) - (distance to [mouse pointer v])) %
end
- awesome-llama
-
1000+ posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
Switch to a larger costume. The sprite size limit depends on the costume. im also using this, but one question, how do you change the minimum size? mine is stuck at 7
switch costume to [large costume v]
set size to (1) %
switch costume to [desired costume v]
- Matthobro120
-
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
-
91 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
-
24 posts
How do you change the size of a sprite based on mouse distance? (The closer the bigger)
thank you so much 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

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