<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Highlander Blog &#187; Box2DFlash</title>
	<atom:link href="http://www.highlander.co.uk/blog/tag/box2dflash/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.highlander.co.uk/blog</link>
	<description>Thoughts and musing from within Highlander</description>
	<lastBuildDate>Thu, 02 Feb 2012 12:05:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The World Construction Kit</title>
		<link>http://www.highlander.co.uk/blog/2010/09/23/the-world-construction-kit/</link>
		<comments>http://www.highlander.co.uk/blog/2010/09/23/the-world-construction-kit/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 09:27:40 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Box2DFlash]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Flash CS5]]></category>
		<category><![CDATA[wck]]></category>
		<category><![CDATA[World Construction Kit]]></category>

		<guid isPermaLink="false">http://www.highlander.co.uk/blog/?p=446</guid>
		<description><![CDATA[In the past, when looking for physics simulations in Actionscript 3, I used Box2DFlash. Although it worked very well, the problem was the documentation.  It was terrible, and it would take me days to work something out and go through various examples, most of which didn&#8217;t apply to the latest version of Box2DFlash, but they <a href='http://www.highlander.co.uk/blog/2010/09/23/the-world-construction-kit/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>In the past, when looking for physics simulations in Actionscript 3, I used Box2DFlash. Although it worked very well, the problem was the documentation.  It was terrible, and it would take me days to work something out and go through various examples, most of which didn&#8217;t apply to the latest version of Box2DFlash, but they were the only examples around.</p>
<p>Eventually I managed get a simple structure together, various boxes moving, bouncing and being able to be controlled by a mouse. I will eventually blog about the example I created as I think it will be a useful exercise for people usingBox2DFlash and for people who wish to see just what is possible in Actionscript 3.</p>
<p>However, when I started to get into more involved structures, joints, pulleys, etc &#8211; things rapidly wnet from bad to worse.  I just did not have the time to go through the morass of outdated tutorials and incorrect information.</p>
<p>Recently I found the World Construction Kit (WCK) &#8211; this a Flash port. It is a component framework for the Box2D Flash Alchemy Port, which allows 2D physics simulations for games / websites to be authored entirely within the Flash IDE.  Whereas, previously I would do everything in Flash Builder, now I can use Flash CS5.</p>
<p>I would also be able to use this in Flash Builder I assume, but I will try that another time. For now I thought I would put together a little example in Flash CS5 and see how easy it is compared to what I did before.</p>
<p>First off a few links…</p>
<p>This is the overview of the World Construction Kit…</p>
<p style="padding-left: 30px"><a target="_blank" rel="nofollow" href="https://github.com/jesses/wck/wiki/world-construction-kit">http://wiki.github.com/jesses/wck/world-construction-kit</a></p>
<p>Download all the files from here…</p>
<p style="padding-left: 30px"><a target="_blank" rel="nofollow" href="https://github.com/jesses/wck">http://github.com/jesses/wck</a></p>
<p>Step by step guide for setting up a simple example here…</p>
<p style="padding-left: 30px"><a target="_blank" rel="nofollow" href="https://github.com/jesses/wck/wiki/step-by-step-wck-quick-start-guide">http://wiki.github.com/jesses/wck/step-by-step-wck-quick-start-guide</a></p>
<p>I basically followed the step-by-step guide, so I will not re-create the whole set of instructions, but what I will do is give you screenshots of what you need to create and what you end up with.</p>
<p>Firstly, this what you end up with when you download your source files…</p>
<div id="attachment_488" class="wp-caption aligncenter" style="width: 187px"><a href="http://www.highlander.co.uk/blog/files/2010/09/dl-files.jpg"><img class="size-medium wp-image-488" src="http://www.highlander.co.uk/blog/wp-content/uploads/2011/07/dl-files-177x300.jpg" alt="downloaded files" width="177" height="300" /></a><p class="wp-caption-text">These are the files you see when you download and uncompress the source files</p></div>
<p>Next create a project folder, and create a test fla &#8211; I am using Flash CS5.  Inside that create a wck-lib folder and copy over the following…</p>
<div id="attachment_490" class="wp-caption aligncenter" style="width: 196px"><a href="http://www.highlander.co.uk/blog/files/2010/09/project-folder.jpg"><img class="size-medium wp-image-490" src="http://www.highlander.co.uk/blog/wp-content/uploads/2011/07/project-folder-186x300.jpg" alt="project folder" width="186" height="300" /></a><p class="wp-caption-text">This is the test project folder with all the source files copied over</p></div>
<p>Once that is done, go back to Flash and look at your fla. You need to create the following…</p>
<div id="attachment_493" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.highlander.co.uk/blog/files/2010/09/wck-test-notes.jpg"><img class="size-medium wp-image-493" src="http://www.highlander.co.uk/blog/wp-content/uploads/2011/07/wck-test-notes-300x147.jpg" alt="wck test file setup" width="300" height="147" /></a><p class="wp-caption-text">World Construction Kit setup</p></div>
<p>Basically you have one MovieClip set up as your world…</p>
<div id="attachment_494" class="wp-caption aligncenter" style="width: 267px"><a href="http://www.highlander.co.uk/blog/files/2010/09/world-setup.jpg"><img class="size-medium wp-image-494" src="http://www.highlander.co.uk/blog/wp-content/uploads/2011/07/world-setup-257x300.jpg" alt="world setup" width="257" height="300" /></a><p class="wp-caption-text">World MovieClip setup</p></div>
<p>Then you create another MovieClip that you will use as your objects within your world. These will be draggable (or not) and can act as walls, etc.</p>
<div id="attachment_495" class="wp-caption aligncenter" style="width: 267px"><a href="http://www.highlander.co.uk/blog/files/2010/09/Rectangle1-setup.jpg"><img class="size-medium wp-image-495" src="http://www.highlander.co.uk/blog/wp-content/uploads/2011/07/Rectangle1-setup-257x300.jpg" alt="Rectangle1 setup" width="257" height="300" /></a></p>
<p><p class="wp-caption-text">Rectangle1 MovieClip setup</p></div>
<p>This MovieClip also needs to have its Component Definition set (just RMB click on the item within the Library)…</p>
<div id="attachment_497" class="wp-caption aligncenter" style="width: 293px"><a href="http://www.highlander.co.uk/blog/files/2010/09/Rectangle1-component-definition1.jpg"><img class="size-medium wp-image-497" src="http://www.highlander.co.uk/blog/wp-content/uploads/2011/07/Rectangle1-component-definition1-283x300.jpg" alt="Rectangle1 component definition" width="283" height="300" /></a><p class="wp-caption-text">Rectangle1 component definition</p></div>
<p>Once this is all done you will have a world created within your fla file, and inside it are your rectangles, one of which will act as your floor. If you were to save and test your file straight away, however, you will notice that both objects fall away &#8211; this is because both are set as dynamic objects.  The object acting as your floor (or wall, etc) needs to be set as a static object.  This is done through the Properties panel…</p>
<div id="attachment_499" class="wp-caption aligncenter" style="width: 91px"><a href="http://www.highlander.co.uk/blog/files/2010/09/instance-properties.jpg"><img class="size-medium wp-image-499" src="http://www.highlander.co.uk/blog/wp-content/uploads/2011/07/instance-properties-81x300.jpg" alt="instance properties" width="81" height="300" /></a><p class="wp-caption-text">Instance properties</p></div>
<p>At the bottom are where you set the types…</p>
<div id="attachment_500" class="wp-caption aligncenter" style="width: 119px"><a href="http://www.highlander.co.uk/blog/wp-content/uploads/2011/07/instance-types.jpg"><img class="size-full wp-image-500" src="http://www.highlander.co.uk/blog/wp-content/uploads/2011/07/instance-types.jpg" alt="instance types" width="109" height="86" /></a><p class="wp-caption-text">Instance types</p></div>
<p>Once set to static, if you then save and test your file you will see one rectangle fall to the floor, the floor stays where it is, and the object can then be moved and thrown with the mouse.</p>
<p>Overall, I found the experience of setting up and working with wck very easy and enjoyable.  I am very impressed with the setup, and the ease with which I could create things. It took maybe half-an-hour of reading and testing to get this simple example working.</p>
<p>The only thing I have noticed is that when I am throwing things around, they sometimes go through other objects, rather than properly colliding &#8211; but this I suspect is down to the values of my settings, things like gravity, friction, restitution, etc. These I will play around with in another post.</p>
<p>My next example will be to see how easy it will be to make various joints and pulleys etc.</p>
<p>A few points…</p>
<p style="padding-left: 30px">the document class is wck.WCK</p>
<p style="padding-left: 30px">you also need to set the following Source and Library paths…</p>
<p style="padding-left: 30px">
<div class="mceTemp mceIEcenter" style="padding-left: 30px">
<dl>
<dt><a href="http://www.highlander.co.uk/blog/files/2010/09/Library-path.jpg"><img class="size-medium wp-image-504" src="http://www.highlander.co.uk/blog/wp-content/uploads/2011/07/Library-path-225x300.jpg" alt="Library path" width="225" height="300" /></a></dt>
<dd>Library path</dd>
</dl>
</div>
<p style="padding-left: 30px">
<div class="mceTemp mceIEcenter" style="padding-left: 30px">
<dl>
<dt><a href="http://www.highlander.co.uk/blog/files/2010/09/Source-path.jpg"><img class="size-medium wp-image-505" src="http://www.highlander.co.uk/blog/wp-content/uploads/2011/07/Source-path-225x300.jpg" alt="Source path" width="225" height="300" /></a></dt>
<dd>Source path</dd>
</dl>
</div>
<p style="padding-left: 30px">
<p style="padding-left: 30px">
<p style="padding-left: 30px">When creating new symbols, make sure that the registration point is in the centre &#8211; Box2D uses the centre point of an object for its calculations</p>
<p style="padding-left: 30px">The world symbol has a Linkage set to wck.World &#8211; all your other objects should exist within an instance of this symbol on the stage</p>
<p style="padding-left: 30px">The box symbols (Rectangle1 in this example) have a Linkage set to shapes.Box</p>
<p style="padding-left: 30px">The Rectangle1 symbol in the Library also has its Component Definition class set to wck.BodyShape</p>
<p>The great thing about this setup is that I can drag out the requisite symbol as many times as I like and position them how I like and change their properties very easily.  Each symbol can also have its own class for me to add whatever behaviours I wish. Very easy.</p>
<p style="padding-left: 30px">
<p>Here are the source files for you to play around with- let me know what you think.</p>
<p><a href="http://www.highlander.co.uk/blog/files/2010/09/wck-test.zip">wck test files</a></p>
<p>Try adding some more walls etc and see what you can do just by throwing around your objects!</p>
<p>Here is the first example that I created…</p>
<p><a href="http://www.highlander.co.uk/blog/files/2010/09/wck-test.swf">wck test1</a></p>
<p>…and here is the second version, I have just added some walls and a ceiling and another object …</p>
<p><a href="http://www.highlander.co.uk/blog/files/2010/09/wck-test2.swf">wck test2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.highlander.co.uk/blog/2010/09/23/the-world-construction-kit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Box2DFlash 2.1 relationships</title>
		<link>http://www.highlander.co.uk/blog/2010/02/22/box2dflash-2-1-relationships/</link>
		<comments>http://www.highlander.co.uk/blog/2010/02/22/box2dflash-2-1-relationships/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 19:41:05 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[Box2DFlash]]></category>
		<category><![CDATA[flash builder]]></category>

		<guid isPermaLink="false">http://www.highlander.co.uk/blog/?p=126</guid>
		<description><![CDATA[As I mentioned previously, Box2DFlash 2.1 is quite different from previous versions of Box2DFlash. The major differences that I have found so far, are related to how to setup your world and your bodies (bearing in mind that I have only just started with Box2DFlash, and do not know the previous versions). It took me <a href='http://www.highlander.co.uk/blog/2010/02/22/box2dflash-2-1-relationships/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>As I mentioned previously, Box2DFlash 2.1 is quite different from previous versions of Box2DFlash.</p>
<p>The major differences that I have found so far, are related to how to setup your world and your bodies (bearing in mind that I have only just started with Box2DFlash, and do not know the previous versions).</p>
<p>It took me a while to get my head around the Box2DFlash 2.1 relationship between fixtures, shapes, and bodies.</p>
<p>So here is a simple graphic that I have created, showing the relationship between a b2Body (your body), a b2BodyDef (body definition, holding information like angle, userData, position, etc), a b2FixtureDef (fixture definition holding information about the physics of the object, i.e. friction, restitution, density, and shape, etc), and a b2PolygonShape (if you are using polygons, and this holds information about the actual shape of your body).</p>
<p>This is to be considered a work in progress, and as I continue with Box2DFlash I may change this.</p>
<p>But for now use it as a good approximation and aide memoire.</p>
<div id="attachment_135" class="wp-caption aligncenter" style="width: 745px"><a href="http://www.highlander.co.uk/blog/wp-content/uploads/2011/07/Box2D-notes4.jpg"><img class="size-full wp-image-135" src="http://www.highlander.co.uk/blog/wp-content/uploads/2011/07/Box2D-notes4.jpg" alt="Box2DFlash body overview" width="735" height="519" /></a><p class="wp-caption-text">Box2DFlash body overview</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.highlander.co.uk/blog/2010/02/22/box2dflash-2-1-relationships/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Box2DFlash</title>
		<link>http://www.highlander.co.uk/blog/2010/02/16/using-box2dflash/</link>
		<comments>http://www.highlander.co.uk/blog/2010/02/16/using-box2dflash/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 22:27:11 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[Box2DFlash]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[flash builder]]></category>

		<guid isPermaLink="false">http://www.highlander.co.uk/blog/?p=122</guid>
		<description><![CDATA[I recently decided to have a play with Box2DFlash. This is a port of a popular 2D physics engine that has been ported to Actionscript 3, Java, C#, etc. A lot of games use Box2DFlash and so I thought it was about time to play around with it. Also, i thought it would be a <a href='http://www.highlander.co.uk/blog/2010/02/16/using-box2dflash/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I recently decided to have a play with Box2DFlash. This is a port of a popular 2D physics engine that has been ported to Actionscript 3, Java, C#, etc.</p>
<p>A lot of games use Box2DFlash and so I thought it was about time to play around with it.</p>
<p>Also, i thought it would be a nice idea to blog about my progress. I will be using Flash Builder 4 (beta) to do all my work in, but the files can be used in Flash, or a.n.other development environment.</p>
<p>Firstly you will need to download the files from here…</p>
<p><a target="_blank" rel="nofollow" href="http://sourceforge.net/projects/box2dflash/develop">http://sourceforge.net/projects/box2dflash/develop</a> (svn)</p>
<p>…or from here…</p>
<p><a target="_blank" rel="nofollow" href="http://www.box2dflash.org/download" target="_blank">http://box2dflash.boristhebrave.com/download</a></p>
<p>Check the latter link to see various examples of how you can use this engine.</p>
<p>The download also contains some test files, so if you do download them, have a look at the test files &#8211; these will give you an insight in how things work.</p>
<p>I will also be using the latest version, 2.1a, and a word of warning &#8211; there is a massive difference between this version and previous versions. As a result, most of the tutorials you will see on the web will not work with 2.1a, so i thought i would use this as an excuse to investigate Box2DFlash 2.1a and see how i can play around with it.</p>
<p>So i will be using Box2DFlash to create various projects in Flash Builder and i will post the code and the results here.</p>
<p>See you soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.highlander.co.uk/blog/2010/02/16/using-box2dflash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

