Home Tutorials Forums Articles Blogs Movies Library Employment Press

 ActionScript.org Forums Create something like Tilt2
 User Name Remember Me? Password
 Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

07-22-2008, 09:49 PM   #1
insanepolak
Registered User

Join Date: Mar 2008
Posts: 28
Create something like Tilt2

I'm trying to make something like Tilt2.

I've got it to tilt moving left and right with the mouse.
But I'm having trouble getting it to tilt and at the same time move with the mouse.

Am I thinking the right way?
Any help would be great
Attached Files
 tilt.zip (5.5 KB, 57 views)

 07-23-2008, 05:14 PM #2 rrh throw a trace() in there   Join Date: Dec 2006 Posts: 1,982 Two things you'll want to learn about: Math.atan2(y,x) Inverse Kinematics
 07-23-2008, 07:02 PM #3 insanepolak Registered User   Join Date: Mar 2008 Posts: 28 Alright so I did some research and got something working. ActionScript Code: ```move = function () {     this._x = _xmouse;     this._y = _ymouse;     var distance_x = stick._x-this._x;     var distance_y = stick._y-this._y;     var alpha = Math.atan2(distance_y, distance_x);     stick._x = this._x+Math.cos(alpha)*totalDistance;     stick._y = this._y+Math.sin(alpha)*totalDistance;     stick._rotation = (Math.PI+alpha)*180/Math.PI;     trace(stick._rotation);     }; press = function () {     this.onMouseMove = move; }; release = function () {     delete this.onMouseMove; }; var totalDistance = 170; ball.onPress = press; ball.onRelease = release; ball.onReleaseOutside = release; ball.move = move;``` Now I'm trying to get the stick to rotate around the ball until it points down, but I'm having trouble making a loop to rotate properly around the ball. I tried to make the rotation point the origin of the stick at 0,0 but then the totalDistance is 0 which screws up the move function rotation.
 07-23-2008, 07:18 PM #4 insanepolak Registered User   Join Date: Mar 2008 Posts: 28 now I've made the ball the mouse, still trying to get the "balance" aspect working.. ActionScript Code: ```onEnterFrame = function() {     ball._x = _xmouse;     ball._y = _ymouse;     ball.onMouseMove = move }; move = function () {     var totalDistance = 170;     this._x = _xmouse;     this._y = _ymouse;     var distance_x = stick._x-this._x;     var distance_y = stick._y-this._y;     var alpha = Math.atan2(distance_y, distance_x);     stick._x = this._x+Math.cos(alpha)*totalDistance;     stick._y = this._y+Math.sin(alpha)*totalDistance;     stick._rotation = (Math.PI+alpha)*180/Math.PI; }; var totalDistance = 170; ball.move = move;```
 07-24-2008, 03:04 PM #5 newblack dondeEstanMisPantalones?     Join Date: Nov 2005 Location: New York Proper Posts: 1,355 i don't really like the end goal (tilt2)... i think that what makes it fun is the physics and they're at best crap. you could use a physics engine like box2d or try to write the equations of motion yourself. depending on how geeky you are the latter could be either horrible or fun. __________________ i am gibreel farishta general relativity jellytanks alpha redux

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home ActionScript Forums Group     ActionScript 3.0     ActionScript 2.0     ActionScript 1.0 (and below)     Simple Stuff (Newbies) Flash General Questions     Flash 10 General Questions     Flash 9 General Questions     Flash 8 General Questions     Other Flash General Questions Flex     Flex 2, 3 & 4     Flex 1 Extensions and Plugins     Components     JSFL - Extending Flash Desktop, Mobile and non-browser Environments     AIR (Apollo)     FlashLite / Portable Devices Development     Projectors and CDs Supporting Technologies     HTML and JavaScript     haXe     Server-Side Scripting     Flash Remoting     Flash Media Server General     Best Practices     Gaming and Game Development     Animation and Effects     Flashants Support Forum Community Boards     General Chat     Just for Kicks Challenges     Detention Flash In Action     Site Check     Cool Sites     Widgets Decommissioned     Projects and Positions CMS Forums     Announcements Board     Content Postings / Updates     Product Review Requests     CMS Technical Questions     Process Questions     Collaboration & Suggested Articles

 Similar Threads Thread Thread Starter Forum Replies Last Post xwielder AIR (Apollo) 1 09-14-2007 08:17 AM mcrodrigues ActionScript 2.0 1 06-02-2007 03:25 AM sadbuttrue ActionScript 2.0 1 02-20-2005 08:18 PM nettemor ActionScript 2.0 4 11-30-2004 02:32 PM lecasn5 Components 61 09-07-2004 11:40 AM

All times are GMT. The time now is 04:44 PM.

///