How do I Make object Always be on cursor.

Get help using Construct 2

Post » Sat Jul 15, 2017 7:52 am

Guys i got a proble. I am making Sprite following cursor. For exampla evrytick-on Left Click is down-Set Sprite position Mouse.x mouse.y yes it works fine but. When i am moving my mouse in game. Mouse is faster then frame in game and that way my cursor leaving my sprite and its stop moving. How can i make my Sprite same fast as my cursor... i mean i want to make sprite stay on cursor all the time(while i am holding left click) and never leave it. Sry for bad english hope someone can help me.
B
13
S
3
G
2
Posts: 34
Reputation: 1,795

Post » Sat Jul 15, 2017 8:32 am

[System] On Start of Layout
[Mouse] Set cursor to None
[Mouse] Set cursor from Sprite

This will turn your cursor into the sprite, that way speed will never be an issue.

Other useful information...
The sprite can not have dimensions larger than 64*64 to be used as a cursor.

The sprite set to cursor will appear as it does in the image editor, not as it does in the layout. Therefore, it will not take scaling/rotating into account.

Also you may wish to include the action "[Sprite] Destroy" following "[Mouse] Set cursor from Sprite" as you will otherwise have a static cursor in your layout which would be an unnecessary object and look odd.
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Sat Jul 15, 2017 10:23 am

Mmm. thank you. maybe then is any way to make my mouse move slower in game?
B
13
S
3
G
2
Posts: 34
Reputation: 1,795

Post » Sat Jul 15, 2017 10:41 am

There is no way to reduce the speed of the cursor that I am aware of, but I think I know what you need to do.

Set the cursor to hidden, and create a helper sprite with pin behavior
On created, pin the helper sprite to the object sprite (Position only)
Tell the helper sprite set position (Mouse.X,Mouse.Y)
Then, tell the object sprite to move X pixels per second at angle (HelperSprite.Angle)

In this way, the object sprite will follow the hidden cursor at the desired speed.
If you only want to be able to "click" on things that the object sprite is overlapping, you can add that as a condition.
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Sat Jul 15, 2017 10:43 am

If I knew what exactly you were trying to accomplish, I could probably offer a better example or alternative. Maybe upload a Capx and some information about what is supposed to be happening with the Mouse/Sprite?
B
11
S
4
G
4
Posts: 28
Reputation: 2,831

Post » Sat Jul 15, 2017 5:59 pm

If you use ajabael code and the have an every tick statement you could the set and objects position to lerp it to the mouse and use dt aswell if you dont understand let me know.
Image
B
24
S
13
G
11
Posts: 277
Reputation: 8,685


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, guannstar, marcinkowski and 22 guests