Make ball object face in the angle of where the cursor is

For questions about using Classic.

Post » Tue Sep 02, 2008 6:00 pm

How do I make the ball object rotate to where the mouse pointer is?

I am trying to make a platform shooting game where you can aim your shots with the mouse. I want to use the ball object because the game idea I have in mind deals with bouncing bullets off of walls in creative ways to solve puzzles, etc.

I tried several things (rotation options, etc) but I can't get the bullets to fire in the direction of the mouse.

http://machriderx.googlepages.com/platform.cap
B
2
S
2
G
4
Posts: 153
Reputation: 1,756

Post » Tue Sep 02, 2008 7:00 pm

After the Create Object action, add a Sprite4 action and select the Ball tab. Set angle of motion to:

angle(Sprite4.X, Sprite4.Y, MouseX, MouseY)
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Tue Sep 02, 2008 7:02 pm

Edit: Ashley wins hehe!
B
2
S
2
G
5
Posts: 391
Reputation: 2,432

Post » Tue Sep 02, 2008 8:56 pm

Thanks again, Ashley. :-)
B
2
S
2
G
4
Posts: 153
Reputation: 1,756

Post » Tue Sep 02, 2008 9:08 pm

Actually, I have another thing I'm confused about.

How do I make it so the ball object destroys itself after 2 bounces? I tried putting a private variable and making it add to the variable every time it collides with a solid, but it doesn't work. When I look at it through debug mode, the variable stays at 0.

I'm also trying to make it play a "ricochet" noise but that doesn't work either when I tell it to play the wav while the bullet collides with the platform. There doesn't seem to be an option to check whether the ball has bounced off of something or not.
B
2
S
2
G
4
Posts: 153
Reputation: 1,756


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests