Page 1 of 1

### How do I - Tennis Ball Far-Near Perspective

Posted: Thu Aug 21, 2014 6:17 am
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

### Re: How do I - Tennis Ball Far-Near Perspective

Posted: Thu Aug 21, 2014 8:58 am
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

### Re: How do I - Tennis Ball Far-Near Perspective

Posted: Thu Aug 21, 2014 9:04 am
One way of doing it:

### Re: How do I - Tennis Ball Far-Near Perspective

Posted: Fri Aug 22, 2014 11:39 am
applehiku wrote: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

### Re: How do I - Tennis Ball Far-Near Perspective

Posted: Fri Aug 22, 2014 12:53 pm
krish wrote:
applehiku wrote: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

### Re: How do I - Tennis Ball Far-Near Perspective

Posted: Fri Aug 22, 2014 2:18 pm
What doesn't work for you in the example I posted?

distance-scale

### Re: How do I - Tennis Ball Far-Near Perspective

Posted: Fri Aug 22, 2014 4:47 pm
LittleStain wrote: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 .. had to step out so late reply... thanks mate!

I'm currently using it like this
Code: Select all
`set Y = 1+0.001*(Bomb.Y-333)`

Could you tell me how you came up with the scale factor
Code: Select all
`0.003*(sprite.Y-100)`
I'm thinking
Code: Select all
`sprite.Y-100`
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.

### Re: How do I - Tennis Ball Far-Near Perspective

Posted: Sun Aug 24, 2014 8:28 am
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..