0 Favourites

Fly Along, Collisions with floor.

  • 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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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)
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Isometric multiple floors
74 9,717
eleanorawesome's avatar
eleanorawesome
Unread hot topic
56 6,150
Tom's avatar
Tom Construct Team Founder
Topic
24 4,582
Lordshiva1948's avatar
Lordshiva1948