## How I can make my ball stand in the middle of my racket?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Bernard51
Prole
Posts: 26
Joined: Fri Jan 20, 2017 5:51 pm

### How I can make my ball stand in the middle of my racket?

Hello
How I can make my ball stand in the middle of my racket?

thank you

https://www.dropbox.com/s/gm28erfiikq25 ... 2.zip?dl=0

raidho36
Party member
Posts: 1516
Joined: Mon Jun 17, 2013 12:00 pm

### Re: How I can make my ball stand in the middle of my racket?

Code: Select all

if ball_should_stick then
ball.x = racket.x + 12
ball.y = racket.y + 34
end


Bernard51
Prole
Posts: 26
Joined: Fri Jan 20, 2017 5:51 pm

### Re: How I can make my ball stand in the middle of my racket?

How I can do now so that my ball is glued to the racket ?

raidho36
Party member
Posts: 1516
Joined: Mon Jun 17, 2013 12:00 pm

### Re: How I can make my ball stand in the middle of my racket?

In the first line of the example I posted, there's a conditional statement. It checks if expression between "if" and "then" evaluates to "true". If you have this variable set to "false" then it will not activate sticking code, if it's set to true - it will.

Bernard51
Prole
Posts: 26
Joined: Fri Jan 20, 2017 5:51 pm

### Re: How I can make my ball stand in the middle of my racket?

Thank you

If I add it it does not work the ball does not stick :

Code: Select all

 if  balle_should_stick and balle.colle == true  then
balle.x = raquette.x + 12
balle.y = raquette.y + 34

end  
At the beginning of the code I put:
-- La balle
local balle = {}
balle.x = 420
balle.y = 550
balle.colle = false

raidho36
Party member
Posts: 1516
Joined: Mon Jun 17, 2013 12:00 pm

### Re: How I can make my ball stand in the middle of my racket?

The "balle_should_stick" is a made-up variable that you substitute with something on your own, it controls whether ball should stick or not. You have there "balle.colle" so you probably don't need that first one. Also since you never set it to anything, it evaluates to "false". You should just remove "balle_should_stick".

Bernard51
Prole
Posts: 26
Joined: Fri Jan 20, 2017 5:51 pm

### Re: How I can make my ball stand in the middle of my racket?

If I do that, it does not work I have more ball

Code: Select all

   if  balle.colle == true  then
balle.x = raquette.x + 12
balle.y = raquette.y + 34

end


### Who is online

Users browsing this forum: No registered users and 6 guests