Page 1 of 1

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

Posted: Fri Feb 17, 2017 1:54 pm
by Bernard51
Hello
How I can make my ball stand in the middle of my racket?
please

thank you

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

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

Posted: Fri Feb 17, 2017 3:08 pm
by raidho36

Code: Select all

if ball_should_stick then
  ball.x = racket.x + 12
  ball.y = racket.y + 34
end
Didn't check your code.

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

Posted: Fri Feb 17, 2017 3:49 pm
by Bernard51
thank you Of your answer

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

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

Posted: Fri Feb 17, 2017 4:02 pm
by raidho36
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.

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

Posted: Fri Feb 17, 2017 4:09 pm
by Bernard51
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

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

Posted: Fri Feb 17, 2017 5:11 pm
by raidho36
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".

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

Posted: Fri Feb 17, 2017 5:50 pm
by Bernard51
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