It looks like you're new here. If you want to get involved, click one of these buttons!

- 7.5K All Categories
- 10 Help with translations
- 4.1K General questions
- 102 Roadmap
- 344 Game & application design
- 302 Plugins
- 68 User experience
- 74 Marketplace
- 284 Code snippets
- 33 Building a team?
- 261 Suggestions & requests
- 349 Announce your apps made with Gideros.
- 90 Step by step tutorials
- 626 Bugs and issues
- 194 Introduce yourself
- 206 Announcements
- 102 Forum talk
- 395 Relax cafe

light
Member

In my billiard game , m showing projection of cue ball on mouse events . Simultaneously i also want to move the billiard stick around the cue ball in the direction of projection on mouse event . How can i do that ?

I have done by calculating slope and some more lengthy stuff .

Just wanted to know, is there an easier way to achieve this.

I have done by calculating slope and some more lengthy stuff .

Just wanted to know, is there an easier way to achieve this.

## Comments

1) x,y position of constant distance away from the ball at provided angle

2) angle in which to rotate the stick so it will always be directed to ball

So lets say your ball is at x1,y1 and mouse is at x2, y2 coordinate.

Calculate a vector

dx = x1-x2

dy = y1-y2

From top of my head:

1) Find a pointX, pointY which, let's say is 100 pixels far from ball on dx,dy vector

2) Find angle of vector

have not tried the code, so may contain errors, but logic should be somewhat correct

More info on similar problems:

http://giderosmobile.com/forum/discussion/2828/new-day-new-problems-rotate-an-physics-object-towards-direction-of-movement/p1

Thanks , i have done something like that and it works . But got stuck to new problem , to hit the cueball with stick i have to pull back stick in that particular line of direction .Dont know how to pull back stick ?

I have seen this kind of behaviour in prismatic joint , but dont know how to apply it here.

Oh yes it was right there . i mean logic