Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] move constant ball on a circle from rotating ball to avoid collision

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #167755
    kadi
    Participant

    http://jsfiddle.net/mF7H5/

    here is the fiddle on what i am trying to do. i want to make one ball on the circle that is constant in position i.e., not spinning. the main aim is to escape constant ball(by assigning a button to jump) from the main ball. if the main ball which is rotating from my fiddle touches any of the constant ball then it should end. one point for each ball escape. i cant position a constant ball on the circle. here is an example of what i like 2 do.here is an example of what i like 2 do. http://www.lessmilk.com/9/

    #167778
    Paulie_D
    Member

    You’re animating the wrong object.

    You don’t want the circle to rotate, you want the ball to rotate.

    http://codepen.io/Paulie-D/pen/ujKsr/

    Idea borrowed from Lea Verou : http://lea.verou.me/2012/02/moving-an-element-along-a-circle/

    Exact positioning of the ‘static’ ball is a little more finicky.

    #167785
    kadi
    Participant

    thanq for the reply. i just modified the code a little bit and compiled on codepen and its working but in jsfiddle doesnt seem to work and dont know what might be the reason. here are the links.

    code pen: http://codepen.io/anon/pen/hKzfl
    jsfiddle: http://jsfiddle.net/DPLCd/

    #167786
    Paulie_D
    Member

    My point was that you should be using the translate numbers to affect the actual position of each ball…not the margin.

    The initial margins just center the ball, the translate options can move it around the ball…and the final positioning was done by adjusting the margin.

    A far amount of math (or JS) is going to be required depending on where you want the balls to be…

    http://cdpn.io/v/LCKxd

    #167790
    kadi
    Participant

    thanq paul for quick reply. i followed ur way to change the translate numbers and its fine. the only problem is its not executing on jsfiddle. so how can i assign a button to move colored balls back and forth to avoid collision from blue ball.

    codepen: http://codepen.io/anon/pen/dIxav
    jsfiddle: http://jsfiddle.net/sfY72/

    #167791
    kadi
    Participant

    code working fine in fiddle as well. just use -webkit-transform to make it work

    #167795
    kadi
    Participant

    so how can i assign a button to move colored balls back and forth to avoid collision from blue ball.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘CSS’ is closed to new topics and replies.