How to make a 4-direction movement?

Get help using Construct 2

Post » Fri Jul 17, 2015 8:22 am

Hello guys and girls!

Is there a way to make a 4-direction movement (only up,down,left and right)? How can I do this? How can I adjust the speed of a sprite in a 4-direction movement?

Thanks in advance!
B
9
S
4
G
3
Posts: 157
Reputation: 2,300

Post » Fri Jul 17, 2015 8:46 am

Image
B
9
S
3
Posts: 153
Reputation: 1,272

Post » Fri Jul 17, 2015 10:37 am

This is 8-direction (not 4-direction)...but I did it ;) Thanks anyway
B
9
S
4
G
3
Posts: 157
Reputation: 2,300

Post » Fri Jul 17, 2015 11:50 am

Oooooooo...I see your point! Thanks! But I don't know how to make it work with mouse: if I click somewhere above my character, the sprite should move up; if I click somewhere below my character, the sprite should move down etc.! Can you please help me?
B
9
S
4
G
3
Posts: 157
Reputation: 2,300

Post » Fri Jul 17, 2015 12:20 pm

If you use the 8-direction behaviour your "player" has the actions 8 direction simulate controll

So you should make events like:

mouse button is down
system compare two values mouse.x >player.x
> player 8 direction simulate control right

You should add more conditions offcourse, because mouse.x can be greater than player.x when the mouse is above the player and you would probably want to simulate up instead..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Jul 17, 2015 12:25 pm

OK! But my character doesn't move...it only moves when I press left/right/up/down arrow on keyboard! How can I make it move when I click a mouse button?
B
9
S
4
G
3
Posts: 157
Reputation: 2,300

Post » Fri Jul 17, 2015 12:36 pm

Set default controls to no in the 8 direction properties and add events like the one I showed above?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Jul 17, 2015 12:40 pm

Oh the event above only works when holding down the mouse button..
If you want a click-event, you should add a variable and change it according to what you want..
Simulate pressing will seem to do almost nothing if it is only called one tick.

so on click
system compare two values mouse.x >player.x
> player set boolean variable moving to yes

player is boolean variable moving
> player 8 direction simulate pressing right
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri Jul 17, 2015 12:47 pm

This is what you get if you do as LittleStain staid. It should work :)

https://dl.dropboxusercontent.com/u/100 ... index.html
B
58
S
24
G
14
Posts: 775
Reputation: 13,166

Post » Fri Jul 17, 2015 1:00 pm

That's just what I need! Do you have a .capx file? If not, I will spend some time playing with this! Thanks guys!!!
B
9
S
4
G
3
Posts: 157
Reputation: 2,300

Next

Return to How do I....?

Who is online

Users browsing this forum: worm1 and 21 guests