Movement question

Get help using Construct 2

Post » Sun Dec 20, 2015 2:09 am

How do you make a sprite move left whit the platform beahviorwhen it comes on screen pass the player and change to moving left when it passed the player and change to moving rigth again when it passed the player twice so it basically follows the player. I tried whit compare x but it doesn't change direction.
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Sun Dec 20, 2015 2:34 am

Havent tested it but try something like this

"direction" global number variable at 0
'On collision sprite with the player ' Event
'add one to direction' action

'direction is greater than 0' event
'every (speed) seconds' event speed meaning lower decimal higher speed
'simulate platform left' action
'direction is greater than 1' event
'every (speed) seconds' event
'simulate platform right' action
'set direction variable to 0' action
B
25
S
11
G
5
Posts: 72
Reputation: 5,059

Post » Sun Dec 20, 2015 2:50 am

I guess I would do it something like this:

Give the Sprite a variable Direction

System pick sprite by comparison Abs(sprite.x-player.x) > 100
-- Sprite.x < player.x
> Sprite set direction : "Right"
-- Else
> Sprite set direction : "Left"

Sprite compare variable direction = "Left"
> Sprite simulate platform pressing left

Sprite compare variable direction = "Right"
> Sprite simulate platform 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 » Wed Dec 30, 2015 11:51 am

MorrisFeldman wrote:Havent tested it but try something like this

"direction" global number variable at 0
'On collision sprite with the player ' Event
'add one to direction' action

'direction is greater than 0' event
'every (speed) seconds' event speed meaning lower decimal higher speed
'simulate platform left' action
'direction is greater than 1' event
'every (speed) seconds' event
'simulate platform right' action
'set direction variable to 0' action


'every (speed) seconds' event speed meaning lower decimal higher speed

How do you create this event? I used compare speed and i couldn't write in that. How do you write in that? Do you use another type of event?
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Thu Feb 04, 2016 8:53 am

I would like to have a clearer vesrion of the previous answer or a new answer.
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Thu Feb 04, 2016 8:55 am

I would like to have a clearer version of the previous answer or a new answer.
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Thu Feb 04, 2016 8:55 am

I would like to have a clearer version of the previous answer or a new answer.
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Thu Feb 04, 2016 4:14 pm

I would like a answer.
B
11
S
2
Posts: 262
Reputation: 1,309

Post » Thu Feb 04, 2016 7:28 pm

Sprite: x < player.x
--- Sprite: simulate platform pressing right

Sprite: x > player.x
--- Sprite: simulate platform pressing left
B
89
S
30
G
95
Posts: 5,160
Reputation: 63,456


Return to How do I....?

Who is online

Users browsing this forum: AkbarAsgharMG, lwgames, Yahoo [Bot] and 3 guests