<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: AS3 Character Movement: Following Mouse with Easing</title>
	<atom:link href="http://asgamer.com/2009/as3-character-movement-following-mouse-with-easing/feed" rel="self" type="application/rss+xml" />
	<link>http://asgamer.com/2009/as3-character-movement-following-mouse-with-easing</link>
	<description>Learn to Make Flash Games, Applications, and Websites</description>
	<lastBuildDate>Fri, 16 Dec 2011 19:32:19 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Dallas</title>
		<link>http://asgamer.com/2009/as3-character-movement-following-mouse-with-easing/comment-page-1#comment-5011</link>
		<dc:creator>Dallas</dc:creator>
		<pubDate>Fri, 11 Jun 2010 10:10:17 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=263#comment-5011</guid>
		<description>I managed to fudge something together.

The previous tutorial used code that would only allow the Hero to travel at the maximum speed. This tutorial calculates movement based off of the speed(sort of like using the speed as an acceleration). That&#039;s the key.

------
if (Math.sqrt(yDistance*yDistance + xDistance*xDistance) &lt; (speed*speed))
  {
    x -= (x - stageRef.mouseX) / (speed);
    y -= (y - stageRef.mouseY) / (speed);		
  }
else
  {
    x += Math.cos(radian) * speed;
    y += Math.sin(radian) * speed;
  }
------

The &#039;if&#039; statement executes the easing statements once the the distance between the mouse and the Hero is equal to the speed*speed, giving you a comfortable amount of room to slow down.

The &#039;else&#039; statement executes the original movement statement (which used speed as the maximum speed) whenever the Hero is too far away from the mouse to begin easing.

What you have left is an object that will move at a maximum speed until it reaches a point to start easing gently to a rest at your mouse position.

Hope I got this right.</description>
		<content:encoded><![CDATA[<p>I managed to fudge something together.</p>
<p>The previous tutorial used code that would only allow the Hero to travel at the maximum speed. This tutorial calculates movement based off of the speed(sort of like using the speed as an acceleration). That&#8217;s the key.</p>
<p>&#8212;&#8212;<br />
if (Math.sqrt(yDistance*yDistance + xDistance*xDistance) &lt; (speed*speed))<br />
  {<br />
    x -= (x &#8211; stageRef.mouseX) / (speed);<br />
    y -= (y &#8211; stageRef.mouseY) / (speed);<br />
  }<br />
else<br />
  {<br />
    x += Math.cos(radian) * speed;<br />
    y += Math.sin(radian) * speed;<br />
  }<br />
&#8212;&#8212;</p>
<p>The &#8216;if&#8217; statement executes the easing statements once the the distance between the mouse and the Hero is equal to the speed*speed, giving you a comfortable amount of room to slow down.</p>
<p>The &#8216;else&#8217; statement executes the original movement statement (which used speed as the maximum speed) whenever the Hero is too far away from the mouse to begin easing.</p>
<p>What you have left is an object that will move at a maximum speed until it reaches a point to start easing gently to a rest at your mouse position.</p>
<p>Hope I got this right.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://asgamer.com/2009/as3-character-movement-following-mouse-with-easing/comment-page-1#comment-4824</link>
		<dc:creator>John</dc:creator>
		<pubDate>Sat, 20 Mar 2010 19:23:12 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=263#comment-4824</guid>
		<description>Whats a good way to add a max speed with easing? I tried: 
if (xMovement &gt; maxSpeed) {
	xMovement = maxSpeed;
}
if (xMovement &lt; -maxSpeed) {
	xMovement = -maxSpeed;
}
I did the same thing with y... it didn&#039;t seem to work right.</description>
		<content:encoded><![CDATA[<p>Whats a good way to add a max speed with easing? I tried:<br />
if (xMovement &gt; maxSpeed) {<br />
	xMovement = maxSpeed;<br />
}<br />
if (xMovement &lt; -maxSpeed) {<br />
	xMovement = -maxSpeed;<br />
}<br />
I did the same thing with y&#8230; it didn&#8217;t seem to work right.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://asgamer.com/2009/as3-character-movement-following-mouse-with-easing/comment-page-1#comment-4557</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Sun, 25 Oct 2009 22:00:25 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=263#comment-4557</guid>
		<description>Nice tut!</description>
		<content:encoded><![CDATA[<p>Nice tut!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dennis</title>
		<link>http://asgamer.com/2009/as3-character-movement-following-mouse-with-easing/comment-page-1#comment-4521</link>
		<dc:creator>Dennis</dc:creator>
		<pubDate>Thu, 27 Aug 2009 10:37:09 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=263#comment-4521</guid>
		<description>I&#039;d like to be able to embed te AS into the swf. Not set the AS class as linkage for the MC. Please help. Thanks</description>
		<content:encoded><![CDATA[<p>I&#8217;d like to be able to embed te AS into the swf. Not set the AS class as linkage for the MC. Please help. Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AS3 Object Oriented Custom Cursor &#124; AS Gamer &#124; Making Flash Games</title>
		<link>http://asgamer.com/2009/as3-character-movement-following-mouse-with-easing/comment-page-1#comment-128</link>
		<dc:creator>AS3 Object Oriented Custom Cursor &#124; AS Gamer &#124; Making Flash Games</dc:creator>
		<pubDate>Tue, 24 Mar 2009 20:11:14 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=263#comment-128</guid>
		<description>[...] Stephent: Just noticed that (Math.sqrt(yDistance*yDistance + xDistance*xDistance) &lt; speed) should be... [...]</description>
		<content:encoded><![CDATA[<p>[...] Stephent: Just noticed that (Math.sqrt(yDistance*yDistance + xDistance*xDistance) &lt; speed) should be&#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Par</title>
		<link>http://asgamer.com/2009/as3-character-movement-following-mouse-with-easing/comment-page-1#comment-118</link>
		<dc:creator>Par</dc:creator>
		<pubDate>Fri, 20 Mar 2009 13:09:12 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=263#comment-118</guid>
		<description>LOL as far as the comment looks... you&#039;ve wrote the same thing twice. But I think I know what you are talking about, I&#039;ll fix it.</description>
		<content:encoded><![CDATA[<p>LOL as far as the comment looks&#8230; you&#8217;ve wrote the same thing twice. But I think I know what you are talking about, I&#8217;ll fix it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephent</title>
		<link>http://asgamer.com/2009/as3-character-movement-following-mouse-with-easing/comment-page-1#comment-117</link>
		<dc:creator>Stephent</dc:creator>
		<pubDate>Fri, 20 Mar 2009 13:05:35 +0000</pubDate>
		<guid isPermaLink="false">http://asgamer.com/?p=263#comment-117</guid>
		<description>Just noticed that (Math.sqrt(yDistance*yDistance +  xDistance*xDistance) &lt; speed) should be

(Math.sqrt(yDistance*yDistance +  xDistance*xDistance) &lt; speed).

ST.</description>
		<content:encoded><![CDATA[<p>Just noticed that (Math.sqrt(yDistance*yDistance +  xDistance*xDistance) &lt; speed) should be</p>
<p>(Math.sqrt(yDistance*yDistance +  xDistance*xDistance) &lt; speed).</p>
<p>ST.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

