Discuss Scratch

gawocko20
Scratcher
30 posts

I need help with mouse trails

I would like to add mouse trails to my project clicky clicker linked HERE
but I can't find a way! can someone help please?
Spentine
Scratcher
1000+ posts

I need help with mouse trails

There are many kinds of mouse trails, so i'm going to show you one example.

when green flag clicked
hide
forever
go to [mouse pointer v]
wait (0.1) secs
create clone of [self v]
end

when I start as a clone
show
go to front
point in direction (pick random (0) to (359))
clear graphic effects
repeat (20)
change [ghost v] effect by (5)
move (2) steps
end
delete this clone

Of course, I just yolo'd the code and I don't know if it actually works or not. You can give it a try if you want.

Last edited by Spentine (Aug. 10, 2022 19:55:27)

legendary34678
Scratcher
1000+ posts

I need help with mouse trails

Spentine's mouse trail could work if you want something like that, but we don't know what you want. What kind of mouse trail are you looking for?
Euglena73
Scratcher
1000+ posts

I need help with mouse trails

You can take a look at a sample Mouse Trail template here: https://scratch.mit.edu/projects/555145507/
gawocko20
Scratcher
30 posts

I need help with mouse trails

Euglena73 wrote:

You can take a look at a sample Mouse Trail template here: https://scratch.mit.edu/projects/555145507/
That did not work. I dont want the mouse trail itself. I cant find a way to click through the mouse trail
gawocko20
Scratcher
30 posts

I need help with mouse trails

Spentine wrote:

There are many kinds of mouse trails, so i'm going to show you one example.

when green flag clicked
hide
forever
go to [mouse pointer v]
wait (0.1) secs
create clone of [self v]
end

when I start as a clone
show
go to front
point in direction (pick random (0) to (359))
clear graphic effects
repeat (20)
change [ghost v] effect by (5)
move (2) steps
end
delete this clone

Of course, I just yolo'd the code and I don't know if it actually works or not. You can give it a try if you want.
That did not work. I dont want the mouse trail itself. I cant find a way to click through the mouse trail
MagentaDude1359
Scratcher
100+ posts

I need help with mouse trails

gawocko20 wrote:

Euglena73 wrote:

You can take a look at a sample Mouse Trail template here: https://scratch.mit.edu/projects/555145507/
That did not work. I dont want the mouse trail itself. I cant find a way to click through the mouse trail
wydm by clicking through the mouse trail?
cactus_bob
Scratcher
100+ posts

I need help with mouse trails

it probably means, since the mouse trail is always at your mouse position and it's in front of everything else, you're always clicking on the mouse trail itself, and the other sprites don't respond to your clicks because you are not clicking on them, you're clicking on the mouse trail

i don't have a solution yet but you should clarify that in the top post so everyone else knows what the problem is
gawocko20
Scratcher
30 posts

I need help with mouse trails

cactus_bob wrote:

it probably means, since the mouse trail is always at your mouse position and it's in front of everything else, you're always clicking on the mouse trail itself, and the other sprites don't respond to your clicks because you are not clicking on them, you're clicking on the mouse trail

i don't have a solution yet but you should clarify that in the top post so everyone else knows what the problem is
Yes, that is what I mean and I would really like help! Even the wikis are wrong! :O
legendary34678
Scratcher
1000+ posts

I need help with mouse trails

Hello! If you have a problem with clicking through your mouse trail, you could always have the mouse trail never spawn on the mouse cursor directly but rather around it and make it so that they disappear quickly.
RT_Borg
Scratcher
1000+ posts

I need help with mouse trails

Hi gawocko20,

Here's a technique that seems to work. I keep track of a past mouse location and create a trail element only when the mouse is a small distance away. The trail element clone (a star) is created in that past location, so it appears just behind where the mouse is moving, and looks right. I took it one step further and have the clone delete itself immediately if it is touched by the mouse while fading away.

Demo: Mouse Trail - Click Friendly
https://scratch.mit.edu/projects/721744134/

Attempted Clicks counts the number of times the mouse goes up and down. Successful Clicks counts the number of clicks received by the full screen nebula sprite.

Even attempting to move the mouse back quickly and click over a star, the counts remain the same. (It may not be impossible, but it's very very rare.)

I hope this helps. I'm happy to answer any questions.

– RT_Borg

Last edited by RT_Borg (Aug. 14, 2022 12:02:22)

gawocko20
Scratcher
30 posts

I need help with mouse trails

RT_Borg wrote:

Hi gawocko20,

Here's a technique that seems to work. I keep track of a past mouse location and create a trail element only when the mouse is a small distance away. The trail element clone (a star) is created in that past location, so it appears just behind where the mouse is moving, and looks right. I took it one step further and have the clone delete itself immediately if it is touched by the mouse while fading away.

Demo: Mouse Trail - Click Friendly
https://scratch.mit.edu/projects/721744134/

Attempted Clicks counts the number of times the mouse goes up and down. Successful Clicks counts the number of clicks received by the full screen nebula sprite.

Even attempting to move the mouse back quickly and click over a star, the counts remain the same. (It may not be impossible, but it's very very rare.)

I hope this helps. I'm happy to answer any questions.

– RT_Borg

That would work, but I need the sprite to stay visible while the mouse clicks.
Game-Creator8
Scratcher
8 posts

I need help with mouse trails

Try if touching mouse trail and mouse down? then…
gawocko20
Scratcher
30 posts

I need help with mouse trails

Game-Creator8 wrote:

Try if touching mouse trail and mouse down? then…
Then what?
RT_Borg
Scratcher
1000+ posts

I need help with mouse trails

Hi gawocko20,

Disregard. See Spentine's answer below.

I assume this is for Clicky Clicker? If so, I see you have a round button you need to click, which is the easiest shape for this.

The idea is that you'll watch for the mouse to go from being up (not down) to being down, which tells you there's a click “somewhere”. Then you just need to see if that “somewhere” (where the mouse is) is inside the circle your button is drawn in. There's a “distance to mouse pointer” that makes this easy, because you just have to see if that distance is less than the radius of your circle.

I've shown how it works here:

Demo: Click Through Another Sprite (circle)
https://scratch.mit.edu/projects/722078410

I hope this helps. Happy to answer any questions.


– RT_Borg

Last edited by RT_Borg (Aug. 16, 2022 05:52:21)

Spentine
Scratcher
1000+ posts

I need help with mouse trails

At this point, don't use the
when this sprite clicked
block.

Do
when green flag clicked
forever
if <mouse down?> then
if <touching [mouse pointer v] ?> then
your code here :: grey
end
wait until <not <mouse down?>>
end
end
instead.

The
<touching [mouse pointer v] ?>
block doesn't care if it's being obscured by mouse trails.

Last edited by Spentine (Aug. 15, 2022 22:53:43)

RT_Borg
Scratcher
1000+ posts

I need help with mouse trails

Spentine wrote:

The
<touching [mouse pointer v] ?>
block doesn't care if it's being obscured by mouse trails.

Oh, thanks Spentine!
6968676665
Scratcher
16 posts

I need help with mouse trails

when green flag clicked
forever
go to [mouse pointer v]
create clone of [myself v]
end

when I start as a clone
repeat (any)
change [color v] effect by (25)

end
end
delete this clone
gawocko20
Scratcher
30 posts

I need help with mouse trails

Spentine wrote:

At this point, don't use the
when this sprite clicked
block.

Do
when green flag clicked
forever
if <mouse down?> then
if <touching [mouse pointer v] ?> then
your code here :: grey
end
wait until <not <mouse down?>>
end
end
instead.

The
<touching [mouse pointer v] ?>
block doesn't care if it's being obscured by mouse trails.
I saw that on the wiki.

I tried that. It still triggers if the sprite is hidden.
RT_Borg
Scratcher
1000+ posts

I need help with mouse trails

I tried that. It still triggers if the sprite is hidden.

I think you're saying that sometimes the button you would click on is hidden, so shouldn't be able to touch the mouse pointer.

Scratch doesn't let you check whether a sprite is shown or hidden with a block, so you would have to keep track yourself, using a variable.

Whenever you have a show or hide block:

show
set [showing v] to [true] // add this

hide
set [showing v] to [false] // add this

And then you can modify Spentine's code as

when green flag clicked
forever
if <mouse down?> then
if <<(showing) = [true]> and <touching [mouse pointer v] ?>> then // check showing
your code here :: grey
end
wait until <not <mouse down?>>
end
end

– RT_Borg

Powered by DjangoBB