How do I move bouncing ball

Get help using Construct 2

Post » Fri Oct 16, 2015 9:42 am

hello to a game I created a bouncing ball continuously, with bullet set: speed 500, gravity 600 , bouce off solids on yes. Now I want to know how to press two buttons to move the ball left and right while bouncing...
thanks for the answers and sorry for English
B
7
S
3
Posts: 54
Reputation: 687

Post » Fri Oct 16, 2015 12:55 pm

B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Fri Oct 16, 2015 2:53 pm

thank you very much but the ball does not move by clicking the button :roll:
B
7
S
3
Posts: 54
Reputation: 687

Post » Fri Oct 16, 2015 3:10 pm

Check this out:
Image

Notice how the ball squishes, and stretches? You want to do that with your sprite's animation.

Set the sprites position with a sine behavior, and use the ABS() so you get an absolute value... this will make it bounce rather than bob up and down.

You can do the above with a lerp too but i am not in the lerp kind of mood right now. Ashleys Sine behavior is much easier to use.

Now you just have to add a little to the sprites +X or -X for the actual movement.

Press rightArrow ----> set Sprite.Position: sprite.x+1

Press LeftArrow ----> set Sprite.Position: sprite.x-1

Tweak the 1 for the speed, the 1 means 1 pixel per frame.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Fri Oct 16, 2015 3:39 pm

gioca72 wrote:..ball does not move by clicking the button :roll:


are you sure?

ball move 1 pix..so...if you hold the button down ball moves..if not..ball stop..
..but it seems that's not what you wanted..

try this one... bouncingBall_2.capx
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Fri Oct 16, 2015 4:51 pm

I do not understand why, the ball bounces but does not move ...... my relase is 212.2 can depend on that?
thanks for your help is important
B
7
S
3
Posts: 54
Reputation: 687

Post » Fri Oct 16, 2015 4:56 pm

jojoe wrote:Check this out:
Image

Notice how the ball squishes, and stretches? You want to do that with your sprite's animation.

Set the sprites position with a sine behavior, and use the ABS() so you get an absolute value... this will make it bounce rather than bob up and down.

You can do the above with a lerp too but i am not in the lerp kind of mood right now. Ashleys Sine behavior is much easier to use.

Now you just have to add a little to the sprites +X or -X for the actual movement.

Press rightArrow ----> set Sprite.Position: sprite.x+1

Press LeftArrow ----> set Sprite.Position: sprite.x-1

Tweak the 1 for the speed, the 1 means 1 pixel per frame.


You can post a picture of the event sheet?
B
7
S
3
Posts: 54
Reputation: 687


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 22 guests