How do I make a sprite move in four directions?

Get help using Construct 2

Post » Sun Apr 16, 2017 5:05 am

Hi guys, my problem is basically with logic, I'm confused about what I should do to make this sprite move in four directions with the simulate controls.
Here I'm using that "edge maker" thing, which is very useful when you want your sprite to move in just two directions, but I want it to move in four, and I'm having problems at it.
Huh, I guess a screenshot may help:

Image

This sprite, as you can see, has a text instance variable called direction that is used to determine the movement orientation through the event actions.
The problem is that the sprite goes to a completely unexpected direction when it hits the boundary maker object, if it was meant to go to the right, it goes up instead, and sometimes it doesn't even hit it at all, it just pass through it like there was nothing there.
Well, that's it, hope you people can help me! Oh, and I'm sorry for my rusty english :roll:, I'm still learning!
Thanks in advance!
B
12
S
2
Posts: 6
Reputation: 614

Post » Sun Apr 16, 2017 5:50 am

Seems kind of simple, but have you tried setting the 8direction to four-directions only in it's settings for the object that has the behavior?
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
46
S
24
G
30
Posts: 516
Reputation: 19,437

Post » Sun Apr 16, 2017 6:17 am

The problem is that in your logic, you have told the variable to change based on it's condition... but it is changing the variable several times in the single event because it's processing your code in-line. You need to have some way of changing the variables in a more controlled way. Currently if the variable is "left" it changes to "right" but is then immediately pocessed from "right" to something else. Maybe adding a "wait 0 seconds" after each state change might work... otherwise you need to break down your state change engine to be more controlled over the variable adjustments.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
80
S
34
G
40
Posts: 3,029
Reputation: 30,393

Post » Sun Apr 16, 2017 8:08 am

Add 'else' in 29, 30 & 31.
B
33
S
18
G
27
Posts: 2,431
Reputation: 20,326

Post » Sun Apr 16, 2017 12:45 pm

99Instances2Go wrote:Add 'else' in 29, 30 & 31.

Yeah, this should also work :D

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
80
S
34
G
40
Posts: 3,029
Reputation: 30,393

Post » Sun Apr 16, 2017 5:24 pm

LaDestitute wrote:Seems kind of simple, but have you tried setting the 8direction to four-directions only in it's settings for the object that has the behavior?

Yes I tried! But it didn't work :(, but now I've found a simpler solution to the problem! Thanks a lot for trying to help me :)!
B
12
S
2
Posts: 6
Reputation: 614

Post » Sun Apr 16, 2017 5:26 pm

SoldjahBoy wrote:The problem is that in your logic, you have told the variable to change based on it's condition... but it is changing the variable several times in the single event because it's processing your code in-line. You need to have some way of changing the variables in a more controlled way. Currently if the variable is "left" it changes to "right" but is then immediately pocessed from "right" to something else. Maybe adding a "wait 0 seconds" after each state change might work... otherwise you need to break down your state change engine to be more controlled over the variable adjustments.

~Sol
Hey, thanks you so much for trying to help me! I've found a simpler and effective solution to the problem! :D
B
12
S
2
Posts: 6
Reputation: 614

Post » Sun Apr 16, 2017 5:27 pm

99Instances2Go wrote:Add 'else' in 29, 30 & 31.

Thank you guy for trying to help me! Really appreciate :D
B
12
S
2
Posts: 6
Reputation: 614

Post » Sun Apr 16, 2017 5:41 pm

Hey people, my thanks to all of you for the help! All your tips helped me come up with a simple solution that I could not see! :) Here it is:

Image

Thanks one more time! Wish you the best.
B
12
S
2
Posts: 6
Reputation: 614


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], mrkaio, Zav and 3 guests