mouse click movement

Get help using Construct 2

Post » Fri Sep 16, 2011 3:41 pm

I think he meant something for beginners - simple behavior that makes sprite follows the mouse cursor or or goes smoothly to mouse position after left/right clicked.
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Sat Sep 17, 2011 11:28 pm

[QUOTE=shinkan] I think he meant something for beginners - simple behavior that makes sprite follows the mouse cursor or or goes smoothly to mouse position after left/right clicked.[/QUOTE]

I did yes, thanks shinkan. Ashley I understand what you are saying in terms of the Bullet behavior. Maybe it could be something we can build upon? From other apps I have looked at it is an obvious behaviour to add.Just remember every noob might come here looking for the same thing and might not really think of using the Bullet behaviour for a player walk behaviour.

A built in behaviour like that with a "Go to and stop" "go to and activate" (where it could launch a different "script" or cobine with a path-finding behavior) could be really powerful and speed up development quite a bit.
Havok2011-09-17 23:33:54
B
19
S
3
G
4
Posts: 79
Reputation: 3,711

Post » Sun Sep 18, 2011 11:24 am

[QUOTE=Ashley] The bullet behavior only needs one event to get it to always move to the mouse (always - set angle to Mouse.X, Mouse.Y). Does that really justify a whole new behavior? [/QUOTE]
The other problem I'm having with this (Using the Bullet Behavior for movement) is that the Sprite stops but is "jumping erratically" at this point. like it's flickering with every tick.
I've tried to come up with a way to check what the previous Mouse click X and Y, programatically I know what I need to check for and what needs to happen, but can't seem to figure that out with the behaviour / event system.
B
19
S
3
G
4
Posts: 79
Reputation: 3,711

Post » Sun Sep 18, 2011 2:29 pm

Stop the the bullet movement once it's within a few pixels of the target. You could use the distance() expression to calculate if it's very close.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Thu Sep 22, 2011 7:25 pm

Where do you put the distance calculations? In a separate event, as a new condition in the same event, or as another action in the same event?

Don't see the fnords and they won't eat you!
B
75
S
16
G
12
Posts: 322
Reputation: 11,608

Post » Thu Sep 22, 2011 8:16 pm

You could try the system 'compare values' condition.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Thu Sep 22, 2011 8:30 pm

I used CustomMovement to create this effect.
I made object variables for the player target X and Y. When the mouse is clicked I set target XY to the mouse XY.
Then I just compare the players XY against his target XY and if they differ I turn the player sprite towards the target XY and give him some acceleration.
When players is near the target XY I stop the movement.

Example capx here

I guess you can use bullet behaviour also the same way.
B
4
S
1
G
2
Posts: 14
Reputation: 1,328

Post » Thu Sep 22, 2011 10:30 pm

@TheLure: the link to your capx isn't working. Is it in the public folder?

@Ashley: Thanks for the hint, i got that mostly working. Unfortunately, the sprite keeps creeping past the mouse click point.

Sorry Havok, I'm not trying to hijack your post.Wastrel2011-09-22 22:32:47
Don't see the fnords and they won't eat you!
B
75
S
16
G
12
Posts: 322
Reputation: 11,608

Post » Thu Sep 22, 2011 11:10 pm

[QUOTE=Wastrel] @TheLure: the link to your capx isn't working. Is it in the public folder?
[/QUOTE]
Agh, there was a space hidden in the end of the URL and I cant edit the post.

Here it is again
B
4
S
1
G
2
Posts: 14
Reputation: 1,328

Post » Fri Sep 23, 2011 10:42 pm

Where can I get more documentation about how to use the bullet system for this (I'm not getting any good results)?

Thanks.
B
7
S
1
G
1
Posts: 37
Reputation: 1,159

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: Callan S and 19 guests