Fly Along, Collisions with floor.

Get help using Construct 2

Post » Tue Feb 18, 2014 12:10 pm

Okay, so I'm making a fly along type game.
I need for when the sprite comes in contact with the floor of the fly along game for the sprite to shrink into it. Causing an affect that makes it look like it is crashing into another planet. With the perspective being correct and everything. So the sprite would be at it's normal set size and then the nearer and nearer it gets towards the floor the smaller and smaller the sprite shrinks into the floor or planet. For example, a UFO landing onto planet earth, BUT this is a slide along game so it is a little bit trick I presume. Also, the floor I'm using, I made my own amazing earth floor, and it's 1400 x 80 so I want to know how I can let that repeat from the end of the image in the game. In other words, I want to know how to successfully and fluently wrap it with no choppy lookingness, Thanks.Slicksz2014-02-18 12:28:21
Posts: 89
Reputation: 619

Post » Tue Feb 18, 2014 12:33 pm

To repeat a background over and over again, I advise you to look at the "infinite runner" template, as it implements something similar.

As for the size of your sprite, the first question is : is your floor always at the same height on the screen ? If so, you just have to check the Y coordinate of your sprite every tick, and set the sprite size accordingly.

For example, let's say you have some Y1, the max height at witch the sprite will begin to shrink, and Y2 the min height, where the sprite should be 0px tall.
Then, the event you need is something along those lines :

System.Every tick (or every X second, X being small)
| If Sprite.Y < Y1 => Sprite.Set scale (1)
| Else Sprite.Set scale (1-(Y-Y1)/(Y2-Y1))
That way :
- if Y < Y1 => the sprite is full size
- if Y = Y1 => scale = 1
- if Y1 < Y < Y2 => the sprite starts to shrink
- if Y = Y2 => scale = 0 (the sprite is 0px tall)
Posts: 461
Reputation: 6,127

Return to How do I....?

Who is online

Users browsing this forum: mrkaio, muquia, tarek2 and 2 guests