How do I - Tennis Ball Far-Near Perspective

0 favourites
  • 8 posts
From the Asset Store
JBoB Sound Studio Casual SFX "Casual Tennis Sound" Pack contain royalty-free stock sound effects.
  • Hey guys,

    Wondering if there is a good way to make a 2d sprite ball scale out and in, creating a perspective of far and near exactly like it was done in NES - Tennis

  • I think you can use this action to enlarge the sprite and replace the "+" for "-" to decrease the size.

    action

    --> set width = self.width+10*dt

    --> set height = self.height+10*dt

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • One way of doing it:

  • I think you can use this action to enlarge the sprite and replace the "+" for "-" to decrease the size.

    action

    --> set width = self.width+10*dt

    --> set height = self.height+10*dt

    But I cannot use every tick there isn't it?

    Then the ball travelling diagonal will decrease in a different rate than when travelled straight?

    How do I use it in reference to it's Y rather than leaving it to time?

    Thanks for response

  • > I think you can use this action to enlarge the sprite and replace the "+" for "-" to decrease the size.

    >

    > action

    > --> set width = self.width+10*dt

    > --> set height = self.height+10*dt

    >

    But I cannot use every tick there isn't it?

    Then the ball travelling diagonal will decrease in a different rate than when travelled straight?

    How do I use it in reference to it's Y rather than leaving it to time?

    Thanks for response

    This is what I quickly can come up with, but if this works, it only makes the ball bigger, when moving up on the Y-axis, instead of smaller. (perhaps it needs a negative value somewhere to inverse it? Poor math skills here)

    Start layout:

    BeginY (Y of where player near camera stands) - EndY (where other player stands) = glob var Difference

    set BallOriginalSize to (ball.width, ball.height)

    every tick:

    set Distance to BeginY-Ball.Y

    set VarThatSetsSize to Distance/Difference

    SpriteBall: set width to VarThatSetsSize * BallOriginalSize

  • What doesn't work for you in the example I posted?

    distance-scale

  • What doesn't work for you in the example I posted?

    distance-scale

    LittleStain

    Hey sorry, your example actually did work a bit for me

    I'm currently using it like this

    set Y = 1+0.001*(Bomb.Y-333)[/code:32kc0lj5]
    
    Could you tell me how you came up with the scale factor [code:32kc0lj5]0.003*(sprite.Y-100)[/code:32kc0lj5] in your code?
    I'm thinking [code:32kc0lj5]sprite.Y-100[/code:32kc0lj5] is because at Y=100 is where you're considering the minimum scale... but couldn't figure out 0.003
    
    Trying to get the ball bounce now   just like the tennis.
  • 0.003 is an arbitrary number..

    I chose to only scale within a certain area and just looked at the size of the sprite when it touched the top of that area and what size I'd like it to have, so the visual appearence made me decide that number I guess (It's been a while since I made this..)

    I guess you could make the scaling based on an expression, taking into account the max y-value, min y-value, max scale and min scale, but this example was more of a proof-of-concept than an actual ready-for-publishing kinda thing..

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)