Change direction of sprites?

Get help using Construct 2

Post » Fri Feb 14, 2014 11:21 am

Hello, I'm trying to make a game similar to SpaceInvader. I need all the aliens on the screen to move horizontally with the following logic: When one strikes the left edge of layout, all aliens change moving to the right, and when they strikes with the right edge, everyone started to move right.

I've been trying to make them change their direction when they hit the edges but without changing their angles but I could not do it. The Alien type has the "bullet" and when i change your moving direction by modifying the angle, are flipped vertically. Thanks and sorry for bad english.
B
2
Posts: 4
Reputation: 158

Post » Fri Feb 14, 2014 12:35 pm

look at the bullet properties - set angle

try setting that to "No"



Also look at the tutorial section - these will really help you get to know construct 2 quicker.RamPackWobble2014-02-14 12:37:23
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,882

Post » Fri Feb 14, 2014 2:32 pm

Change "angle set" to "no" and just the sprite changes direction but still fliping vertically. This is the logic I want to achieve:

if (Alien.X > LayoutWidth) then (Move Alien to the right without flip the image vertically)

if (Alien.X < 0) then (Move Alien to the left without flip the image vertically)
B
2
Posts: 4
Reputation: 158

Post » Fri Feb 14, 2014 2:38 pm

I got it:
if (Alien.X> LayoutWidth) then (Invasor.Bullet.Speed ??* -1)

But if i put it:
if (Alien.X < 0) then (Invasor.Bullet.Speed ??* -1)

The logic is cancelled. Any help?

There is a event called "is outside layout" but with it i dont change the point of hit, for example: (Alien.X > LayoutWidth - 100)bluesystem2014-02-14 14:48:27
B
2
Posts: 4
Reputation: 158

Post » Fri Feb 14, 2014 2:55 pm

Solved: Put conditions in separate events.
B
2
Posts: 4
Reputation: 158

Post » Fri Feb 14, 2014 4:08 pm

sorry for the late reply.

here is a very simple space invader left/right using bullets
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,882

Post » Fri Feb 14, 2014 5:06 pm

Well, the way i see it, they aren't flipped, but just rotated, as you rotate the whole sprite, not just the speed vector.
If you want to change the movement direction by 180 degrees, you could either:
1.) set the speed to a negative value, for example
"when sprite at necessary position / collides with the border -> sprite(bullet)speed = sprite(bullet)speed * (-1)"
2.) rotate the sprite by 180 degrees and flip it vertically, you'd do this by setting the height to a negative value
"when sprite at necessary position / collides with the border -> spriteheight = spriteheight * (-1)"
horizontal flipping could be necessary, also.Stiivais2014-02-14 17:14:26
B
10
S
1
Posts: 163
Reputation: 1,436


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, Blendi1223, dop2000 and 56 guests