Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Physics question

Author
Message
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 12th Apr 2012 23:38 Edited at: 12th Apr 2012 23:39
I have absolute ZERO knowledge of the intricate world of Physics apart from the very basics = setting up sprites & collision.

I want to make a fan, the user wipes from either side, and the fan rotates that way.

I suppose I will have to create some kind of fixed axis in the middle of the fan, and apply some force depending on the swipe.

What kind of commands should I look for? I checked the manual, but there are so many different physics commands that i have no clue about...

Please don't post complete code, I just need an indication where I should start looking!!!
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 13th Apr 2012 00:23
You could get the contact point between the touch and the fan blade, then get the distance the swipe moved over a set time, (to get the speed) then apply a force to the revolute joint to spin the blades.

"here is a an expression to remember - He who has the gold makes the rules."
Paypal disagreed!
victordavion
12
Years of Service
User Offline
Joined: 3rd Jan 2012
Location:
Posted: 13th Apr 2012 06:02 Edited at: 13th Apr 2012 06:04
Alright, I won't give you the code, but here's where I would look:

Firstly, you'll need to have the sprite respond to physics from other objects most likely, so in order for it to stay where it is, look in the Joint section under Physics.

If you're not needing the player to literally push the fan blades then you can save some processing by using a simple shape on the fan (non pixel perfect collision).

Look at commands SetSpritePhysicsAngularVelocity or preferably SetSpritePhysicsAngularImpulse or possibly SetSpritePhysicsTorque.

If you're using raw touch commands, use type 3 ( drag ) and you can use the startX/Y and currentX/Y to calculate a distance the mouse (or pointer) has dragged and convert that into a scaled force (torque).

If you're using the GetPointerPressed()/Released() commands, just be sure to store the x/y values when it's pressed, and again when it's released to calculate that distance. ( I prefer raw touch commands ).

I think that just about sums up what my process would be. Let me know how it goes.

Edit: Sorry I forgot to mention. For the direction, of course, you can check the current X/Y of the mouse against the start X/Y to get your direction (subtract and if positive -> or negative <- ).
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 13th Apr 2012 13:33
I was planing to sue GetPointerPressed()/Released() to get the swipe distance, then calculate the distance as a % of the width of the screen and that would be the force applied.

I will check out JOINTS but there are so many commands that it's hard to select which one would fit best, with no experience!

However thanks a lot!

Login to post a reply

Server time is: 2024-11-23 08:49:06
Your offset time is: 2024-11-23 08:49:06