How do I - Tennis Ball Far-Near Perspective

Get help using Construct 2

Post » 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

http://www.youtube.com/watch?v=vixHWpvK1ys
B
21
S
6
G
5
Posts: 391
Reputation: 5,662

Post » 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
My latest game is: Plants at www.rogerty.com
B
28
S
6
G
7
Posts: 683
Reputation: 5,686

Post » Thu Aug 21, 2014 9:04 am

One way of doing it:
You do not have the required permissions to view the files attached to this post.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » 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 :)
B
21
S
6
G
5
Posts: 391
Reputation: 5,662

Post » 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
My latest game is: Plants at www.rogerty.com
B
28
S
6
G
7
Posts: 683
Reputation: 5,686

Post » Fri Aug 22, 2014 2:18 pm

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

distance-scale
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » 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! :D

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)
in your code?
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.
B
21
S
6
G
5
Posts: 391
Reputation: 5,662

Post » 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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: dereck28 and 19 guests