How do I make an object go back in mirror

Get help using Construct 2

Post » Fri Mar 28, 2014 8:46 pm

Hey guys,

So I have this evil, malefic... fly :) that starts on the right side of the screen and goes all the way to the left side. What I want to do, is to go back once it reaches the left side of the screen (left limit of the layout), so it will have this track: <------------ then ----------->.
Sorry if the questions seems stupid, I'm new to C2 :)


Regards,

Andrei
B
8
S
1
Posts: 20
Reputation: 567

Post » Sat Mar 29, 2014 2:50 pm

See if this helps:
You do not have the required permissions to view the files attached to this post.
B
17
S
4
G
3
Posts: 172
Reputation: 1,933

Post » Sat Mar 29, 2014 3:37 pm

It's great! Thanks. Can you explain it a bit please? I need to understand it, and then to make it stay at a certain height.
B
8
S
1
Posts: 20
Reputation: 567

Post » Sat Mar 29, 2014 4:08 pm

Sure... There are 2 events.

With the first event:
With evilFly | X >= WindowWidth - floor(Self.Width/2)

I'm saying with evilFly's X value is equal to or greater than the width of the window, less half of the width of the width of evilFly.

The Self.Width/2 means half of the width of evilFly. I'm using half of evilFly because evilFly's origin is in the center. So by subtracting half the width of evelFly I'm reversing evilFly's direction while evilFly is still completely in the window.
The floor() is in there so that if there is a remainder when I divide the width of evilFly by 2, any remainder will be dropped.

So when this event happens I change evilFly's Bullet angle of motion to -180, which sends it to the left. By the way you don't need the "-". If you use just 180 it means the same thing. I accidentally left the "-" in there.

So with the event:
evilFly | X <+ round(Self.Width/2)

I'm basically doing the same thing for the left side. I could have used floor() here instead of round(). In either case evilFly would reverse direction while completely inside the window.

So when this event happens I change evilFly's Bullet angle of motion to 0, which sends it to the right.

By the way, I have a Bound to layout Behavior on evilFly. It's not necessary. It's just another one of those things I accidentally left in.
B
17
S
4
G
3
Posts: 172
Reputation: 1,933


Return to How do I....?

Who is online

Users browsing this forum: David181, dop2000, jorgmaquoi, unicornspitfire and 32 guests