<?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>RevoluGame &#187; NME</title>
	<atom:link href="http://revolugame.com/tag/nme/feed/" rel="self" type="application/rss+xml" />
	<link>http://revolugame.com</link>
	<description>Web and Game development</description>
	<lastBuildDate>Sun, 02 Jun 2013 17:06:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>A quick start with nape and tilelayer</title>
		<link>http://revolugame.com/a-quick-start-with-nape-and-tilelayer/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-quick-start-with-nape-and-tilelayer</link>
		<comments>http://revolugame.com/a-quick-start-with-nape-and-tilelayer/#comments</comments>
		<pubDate>Wed, 26 Dec 2012 22:28:47 +0000</pubDate>
		<dc:creator>Adrien</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[nape]]></category>
		<category><![CDATA[NME]]></category>

		<guid isPermaLink="false">http://revolugame.com/?p=701</guid>
		<description><![CDATA[<p>Recently, I started a mobile game with NME, and I wanted to give a try to nape. Since I&#8217;ve seen the NME&#8217;s runnermark, I&#8217;ve wanted to try the tilelayer library too. So why not dot it at the same time !
Overall view
Nape
This month was annonced the 2.0 version of nape. Nape is an open-source Haxe/AS3  [...]</p><p>The post <a href="http://revolugame.com/a-quick-start-with-nape-and-tilelayer/">A quick start with nape and tilelayer</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Recently, I started a mobile game with <strong>NME</strong>, and I wanted to give a try to <a href="http://napephys.com" target="_blank">nape</a>. Since I&#8217;ve seen the <a href="https://github.com/elsassph/nme-runnermark" target="_blank">NME&#8217;s runnermark</a>, I&#8217;ve wanted to try the <a href="https://github.com/elsassph/nme-tilelayer" target="_blank">tilelayer</a> library too. So why not dot it at the same time !</p>
<h2>Overall view</h2>
<h3>Nape</h3>
<p>This month was annonced the <strong>2.0 version of nape</strong>. Nape is an <strong>open-source Haxe/AS3 physics engine</strong> that lets you do <strong>cross platform</strong> applications. It&#8217;s fast and powerful (actually I prefer <strong>nape</strong> over <strong>box2d</strong>, it&#8217;s much easier to use, and really fast). See by yourself : <a href="http://napephys.com/samples.html" target="_blank">http://napephys.com/samples.html</a>.</p>
<p>Just download it through <a href="http://lib.haxe.org/p/nape" target="_blank">haxelib</a> :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="code" style="font-family:monospace;">haxelib install nape</pre></td></tr></table></div>

<h3>Tilelayer</h3>
<p>To quote the github description :</p>
<blockquote><p>
A lightweight and very optimized wrapper over NME&#8217;s powerful but lowlevel &#8216;drawTiles&#8217; which offers the best rendering performance (ie. batching) on native platforms.
</p></blockquote>
<p>To install the <a href="http://lib.haxe.org/p/tilelayer" target="_blank">haxelib</a> version :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="code" style="font-family:monospace;">haxelib install tilelayer</pre></td></tr></table></div>

<p><span id="more-701"></span></p>
<h2>Simple implementation</h2>
<p>So now to use these two great libraries :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">import</span> <span style="color: #006699;">nape.phys.Body</span><span style="color: #339933;">;</span>
<span style="color: #6699cc; font-weight: bold;">import</span> <span style="color: #006699;">aze.display.TileSprite</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">class</span> Entity
<span style="color: #000000;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// The tilelayer's sprite</span>
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> sprite<span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">default</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">:</span> TileSprite<span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// The nape's body</span>
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> body<span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">default</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #339933;">:</span> Body<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> <span style="color: #6699cc; font-weight: bold;">new</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * Update the positions and the rotation
     **/</span>
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #6699cc; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>sprite <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> body <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            sprite.<span style="color: #006633;">x</span> <span style="color: #339933;">=</span> body.<span style="color: #006633;">position</span>.<span style="color: #006633;">x</span><span style="color: #339933;">;</span>
            sprite.<span style="color: #006633;">y</span> <span style="color: #339933;">=</span> body.<span style="color: #006633;">position</span>.<span style="color: #006633;">y</span><span style="color: #339933;">;</span>
            sprite.<span style="color: #006633;">rotation</span> <span style="color: #339933;">=</span> body.<span style="color: #006633;">rotation</span><span style="color: #339933;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>All the entities will have to be updated on <strong>each frame</strong>, as well as the nape&#8217;s space and the layer :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> _space <span style="color: #339933;">:</span> Space<span style="color: #339933;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> _layer <span style="color: #339933;">:</span> TileLayer<span style="color: #339933;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> _entities <span style="color: #339933;">:</span> List<span style="color: #339933;">&lt;</span>Entity<span style="color: #339933;">&gt;;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> <span style="color: #6699cc; font-weight: bold;">new</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #6699cc; font-weight: bold;">var</span> tilesheet <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> SparrowTilesheet<span style="color: #000000;">&#40;</span>
        Assets.<span style="color: #006633;">getBitmapData</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">&quot;assets/spritesheet.png&quot;</span><span style="color: #000000;">&#41;</span>, 
        Assets.<span style="color: #006633;">getText</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">&quot;assets/spritesheet.xml&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
    _layer <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> TileLayer<span style="color: #000000;">&#40;</span>tilesheet<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
    addChild<span style="color: #000000;">&#40;</span>_layer.<span style="color: #006633;">view</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    _space <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> Space<span style="color: #000000;">&#40;</span> <span style="color: #6699cc; font-weight: bold;">new</span> Vec2<span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">600</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    _space.<span style="color: #006633;">step</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">60</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #6699cc; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span>entity <span style="color: #6699cc; font-weight: bold;">in</span> _entities<span style="color: #000000;">&#41;</span>
        entity.<span style="color: #006633;">update</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
    _layer.<span style="color: #006633;">render</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Now to define a simple rectangular entity :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">class</span> Box <span style="color: #6699cc; font-weight: bold;">extends</span> Entity
<span style="color: #000000;">&#123;</span>
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> <span style="color: #6699cc; font-weight: bold;">new</span><span style="color: #000000;">&#40;</span>pSpace<span style="color: #339933;">:</span> Space<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #6699cc; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Nape's data</span>
        body <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> Body<span style="color: #000000;">&#40;</span>BodyType.<span style="color: #006633;">DYNAMIC</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        body.<span style="color: #006633;">shapes</span>.<span style="color: #006633;">add</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">new</span> Polygon<span style="color: #000000;">&#40;</span>Polygon.<span style="color: #006633;">box</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">50</span>, <span style="color: #cc66cc;">50</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        body.<span style="color: #006633;">position</span>.<span style="color: #006633;">setxy</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">10</span>, <span style="color: #cc66cc;">10</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        body.<span style="color: #006633;">space</span> <span style="color: #339933;">=</span> pSpace<span style="color: #339933;">;</span>
&nbsp;
        sprite <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> TileSprite<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">'box'</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>And simply add it to the stage :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> box <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> Box<span style="color: #000000;">&#40;</span>_space<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
_entities.<span style="color: #006633;">add</span><span style="color: #000000;">&#40;</span>box<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
_layer.<span style="color: #006633;">addChild</span><span style="color: #000000;">&#40;</span> box.<span style="color: #006633;">sprite</span> <span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The post <a href="http://revolugame.com/a-quick-start-with-nape-and-tilelayer/">A quick start with nape and tilelayer</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://revolugame.com/a-quick-start-with-nape-and-tilelayer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AGE &#8211; How to support physic engines</title>
		<link>http://revolugame.com/age-how-to-support-physic-engines/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=age-how-to-support-physic-engines</link>
		<comments>http://revolugame.com/age-how-to-support-physic-engines/#comments</comments>
		<pubDate>Sat, 17 Nov 2012 16:54:06 +0000</pubDate>
		<dc:creator>Adrien</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AGE]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[NME]]></category>

		<guid isPermaLink="false">http://revolugame.com/?p=616</guid>
		<description><![CDATA[<p>In the previous post, we have seen how to use the Box2D support into the AGE engine. Now I just want to show you how simple it is to add a new framework/engine support.
For example, we are going to add the Nape support.
For those of you who don&#8217;t know, Nape is a Haxe/AS3 physics engine. Since Nape  [...]</p><p>The post <a href="http://revolugame.com/age-how-to-support-physic-engines/">AGE &#8211; How to support physic engines</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>In the previous post, we have seen how to use <a href="http://revolugame.com/age-box2d-support/" title="AGE – Box2D support">the Box2D support</a> into the <strong>AGE engine</strong>. Now I just want to show you how simple it is to add a new framework/engine support.</p>
<p>For example, we are going to add the <a href="https://github.com/deltaluca/nape/" target="_blank">Nape</a> support.</p>
<p>For those of you who don&#8217;t know, <strong>Nape</strong> is a <strong>Haxe/AS3</strong> physics engine. Since <strong>Nape</strong> is really close to <strong>Box2D</strong>, it will be simple to understand how <strong>box2d</strong> has been added to <strong>AGE</strong>.</p>
<h2>The behavior</h2>
<p>Since <strong>AGE</strong> is based on a <strong>behaviors system</strong>, we are just going to create a new behavior, that we will call <strong>NapeMovementBehavior</strong> :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">class</span> NapeMovementBehavior <span style="color: #6699cc; font-weight: bold;">implements</span> IBehavior
<span style="color: #000000;">&#123;</span>
    <span style="color: #6699cc; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _entity <span style="color: #339933;">:</span> BasicEntity<span style="color: #339933;">;</span>
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> enabled<span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">default</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000033; font-weight: bold;">Bool</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000033; font-weight: bold;">Void</span> <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> enable<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
	enabled <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> disable<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
	enabled <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> destroy<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000033; font-weight: bold;">Void</span> <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Now we are going to <strong>initialize</strong> the data needed by <strong>Nape</strong> for the behavior&#8217;s entity :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _body <span style="color: #339933;">:</span> Body<span style="color: #339933;">;</span>
<span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">static</span> <span style="color: #6699cc; font-weight: bold;">var</span> world <span style="color: #339933;">:</span> Space<span style="color: #339933;">;</span>
<span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> <span style="color: #6699cc; font-weight: bold;">new</span><span style="color: #000000;">&#40;</span>pEntity<span style="color: #339933;">:</span> BasicEntity, pDynamic<span style="color: #339933;">:</span><span style="color: #000033; font-weight: bold;">Bool</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #6699cc; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>world <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
        world <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> Space<span style="color: #000000;">&#40;</span> <span style="color: #6699cc; font-weight: bold;">new</span> Vec2<span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">500</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    _body <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> Body<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span>pDynamic <span style="color: #339933;">?</span> BodyType.<span style="color: #006633;">DYNAMIC</span> <span style="color: #339933;">:</span> BodyType.<span style="color: #006633;">STATIC</span><span style="color: #000000;">&#41;</span>, 
                       <span style="color: #6699cc; font-weight: bold;">new</span> Vec2<span style="color: #000000;">&#40;</span>pEntity.<span style="color: #006633;">x</span> <span style="color: #339933;">+</span> pEntity.<span style="color: #006633;">halfWidth</span>, pEntity.<span style="color: #006633;">y</span> <span style="color: #339933;">+</span> pEntity.<span style="color: #006633;">halfHeight</span><span style="color: #000000;">&#41;</span>
                   <span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #6699cc; font-weight: bold;">var</span> block<span style="color: #339933;">:</span>Polygon <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> Polygon<span style="color: #000000;">&#40;</span>Polygon.<span style="color: #006633;">box</span><span style="color: #000000;">&#40;</span>pEntity.<span style="color: #006633;">width</span>,pEntity.<span style="color: #006633;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    _body.<span style="color: #006633;">shapes</span>.<span style="color: #006633;">add</span><span style="color: #000000;">&#40;</span>block<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
    _body.<span style="color: #006633;">align</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    _body.<span style="color: #006633;">space</span> <span style="color: #339933;">=</span> world<span style="color: #339933;">;</span>
&nbsp;
    _entity <span style="color: #339933;">=</span> pEntity<span style="color: #339933;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>If you need more information on how <strong>Nape</strong> is working, go check the <a href="http://deltaluca.me.uk/docnew/" target="_blank">documentation</a>.<br />
So for now, we have a basic entity initialized for working into Nape.<br />
<span id="more-616"></span><br />
We have to <strong>update</strong> the <strong>entity position</strong> into the game based on the Nape&#8217;s one :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000033; font-weight: bold;">Void</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #330000; font-weight: bold;">#if</span> cpp
    _entity.<span style="color: #006633;">x</span> <span style="color: #339933;">=</span> _body.<span style="color: #006633;">position</span>.<span style="color: #006633;">x</span><span style="color: #339933;">;</span>
    _entity.<span style="color: #006633;">y</span> <span style="color: #339933;">=</span> _body.<span style="color: #006633;">position</span>.<span style="color: #006633;">y</span><span style="color: #339933;">;</span>
    <span style="color: #330000; font-weight: bold;">#else</span>
    _entity.<span style="color: #006633;">x</span> <span style="color: #339933;">=</span> _body.<span style="color: #006633;">position</span>.<span style="color: #006633;">x</span> <span style="color: #339933;">-</span> _entity.<span style="color: #006633;">halfWidth</span><span style="color: #339933;">;</span>
    _entity.<span style="color: #006633;">y</span> <span style="color: #339933;">=</span> _body.<span style="color: #006633;">position</span>.<span style="color: #006633;">y</span> <span style="color: #339933;">-</span> _entity.<span style="color: #006633;">halfHeight</span><span style="color: #339933;">;</span>
    <span style="color: #330000; font-weight: bold;">#end</span>
&nbsp;
    _entity.<span style="color: #006633;">rotation</span> <span style="color: #339933;">=</span> _body.<span style="color: #006633;">rotation</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">57.2957795</span><span style="color: #339933;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>There is some differences between c++ and flash: with the flash renderer, we must have the center point at the top left position (for now).</p>
<p>Now the destroy function (called after the behavior has been removed) :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> destroy<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000033; font-weight: bold;">Void</span>
<span style="color: #000000;">&#123;</span>
    world.<span style="color: #006633;">bodies</span>.<span style="color: #006633;">remove</span><span style="color: #000000;">&#40;</span>_body<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>If you have noticed, the <strong>world</strong> variable is <strong>static</strong>, because we have to update it on each frame. So to keep the behaviors system intact, we are going to use the <strong>BehaviorsManager</strong> :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> <span style="color: #6699cc; font-weight: bold;">new</span><span style="color: #000000;">&#40;</span>pEntity<span style="color: #339933;">:</span> BasicEntity, pDynamic<span style="color: #339933;">:</span><span style="color: #000033; font-weight: bold;">Bool</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #6699cc; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>world <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>    
	world <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> Space<span style="color: #000000;">&#40;</span> <span style="color: #6699cc; font-weight: bold;">new</span> Vec2<span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">500</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>        
        BehaviorsManager.<span style="color: #006633;">getInstance</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #006633;">registerUpdater</span><span style="color: #000000;">&#40;</span>globalUpdate<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// [...]</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Now the <strong>globalUpdate()</strong> function is going to be called on each frame :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> globalUpdate<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000033; font-weight: bold;">Void</span>
<span style="color: #000000;">&#123;</span>
    world.<span style="color: #006633;">step</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">30</span>, <span style="color: #cc66cc;">10</span>, <span style="color: #cc66cc;">10</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<h2>How to use it ?</h2>
<p>Now to use this behavior with an entity, just add the <strong>NapeMovementBehavior</strong> to the behaviors list :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> e <span style="color: #339933;">:</span> BasicEntity <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> BasicEntity<span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
e.<span style="color: #006633;">makeGraphic</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">32</span>, <span style="color: #cc66cc;">32</span>, 0xFFFF0000<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// create a rectangle</span>
e.<span style="color: #006633;">addBehavior</span><span style="color: #000000;">&#40;</span> <span style="color: #6699cc; font-weight: bold;">new</span> NapeMovementBehavior<span style="color: #000000;">&#40;</span>e, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// add the behavior</span>
add<span style="color: #000000;">&#40;</span>e<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// add the entity to the game</span></pre></td></tr></table></div>

<p>Here is a quick demo (drag the blocks) :</p>

    <div id="swfobj_0">
      
    </div>

<p>You can see the <strong>NapeMovementBehavior</strong> class <a href="https://github.com/po8rewq/AGE/blob/master/src/com/revolugame/age/behaviors/NapeMovementBehavior.hx" title="NapeMovementBehavior.hx" target="_blank">here</a> and the <strong>NapeEntity</strong> class <a href="https://github.com/po8rewq/AGE/blob/master/src/com/revolugame/age/display/NapeEntity.hx" title="NapeEntity.hx" target="_blank">here</a>.</p>
<p>The post <a href="http://revolugame.com/age-how-to-support-physic-engines/">AGE &#8211; How to support physic engines</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://revolugame.com/age-how-to-support-physic-engines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AGE &#8211; Box2D support</title>
		<link>http://revolugame.com/age-box2d-support/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=age-box2d-support</link>
		<comments>http://revolugame.com/age-box2d-support/#comments</comments>
		<pubDate>Sat, 10 Nov 2012 17:43:08 +0000</pubDate>
		<dc:creator>Adrien</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AGE]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[NME]]></category>

		<guid isPermaLink="false">http://revolugame.com/?p=576</guid>
		<description><![CDATA[<p>Since Box2D is one of the most used physics engine, I&#8217;ve started to implement it into the AGE game engine. 
I&#8217;ve used the box2d version from haxelib, so don&#8217;t forget to add the following to your nmml file :

&#60;haxelib name=&#34;box2d&#34; /&#62;

I&#8217;ve implemented it with the behaviors system. So now we have a  [...]</p><p>The post <a href="http://revolugame.com/age-box2d-support/">AGE &#8211; Box2D support</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Since <a href="http://box2d.org/" target="_blank">Box2D</a> is one of the most used <strong>physics engine</strong>, I&#8217;ve started to implement it into the AGE game engine. </p>
<p>I&#8217;ve used the box2d version from <a href="http://lib.haxe.org/p/box2d" target="_blank">haxelib</a>, so don&#8217;t forget to add the following to your nmml file :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;haxelib</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;box2d&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>I&#8217;ve implemented it with the <strong>behaviors system</strong>. So now we have a <strong>Box2dEntity</strong> that has a special Behavior (Box2dMovementBehavior) which initialize and update all the Box2D stuff.</p>
<p>For example, to define an entity :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">import</span> <span style="color: #006699;">com.revolugame.age.display.Box2dEntity</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">class</span> Block <span style="color: #6699cc; font-weight: bold;">extends</span> Box2dEntity
<span style="color: #000000;">&#123;</span>
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> <span style="color: #6699cc; font-weight: bold;">new</span> <span style="color: #000000;">&#40;</span>pX<span style="color: #339933;">:</span> <span style="color: #000033; font-weight: bold;">Int</span>, pY<span style="color: #339933;">:</span> <span style="color: #000033; font-weight: bold;">Int</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #6699cc; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>pX, pY<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        makeGraphic<span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">32</span>, <span style="color: #cc66cc;">32</span>, 0xFF000000<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        initBox2dStuff<span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">30</span>, <span style="color: #000066; font-weight: bold;">true</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//                                     ^ friction</span>
<span style="color: #666666; font-style: italic;">//                                  ^ restitution</span>
<span style="color: #666666; font-style: italic;">//                               ^ density</span>
<span style="color: #666666; font-style: italic;">//                          ^ if the entity is dynamic</span>
<span style="color: #666666; font-style: italic;">//                     ^ conversion meters to pixels</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;">add<span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">new</span> Block<span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">10</span>, <span style="color: #cc66cc;">50</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And that&#8217;s it !</p>
<p>The <strong>Box2D</strong> support works with <strong>Flash</strong> and <strong>C++</strong> but needs some optimization for now.<br />
<span id="more-576"></span><br />
Here is a quick example (click on the blocks to remove them) :</p>

    <div id="swfobj_1">
      
    </div>

<p>You can also apply a <strong>force</strong> or an <strong>impulse</strong> on your entity :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;">_b2dBehavior.<span style="color: #006633;">applyImpulse</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">2</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// x, y</span>
_b2dBehavior.<span style="color: #006633;">applyForce</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">2</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// x, y</span></pre></td></tr></table></div>

<p>Another example (click on the oranges to apply a random impulse) :</p>

    <div id="swfobj_2">
      
    </div>

<p>For more information on <strong>Box2D</strong>, check out <a href="http://www.box2dflash.org/docs/2.0.2/manual" target="_blank">the flash documentation</a>.</p>
<p>The post <a href="http://revolugame.com/age-box2d-support/">AGE &#8211; Box2D support</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://revolugame.com/age-box2d-support/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AGE &#8211; QuadTree implementation</title>
		<link>http://revolugame.com/age-quadtree-implementation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=age-quadtree-implementation</link>
		<comments>http://revolugame.com/age-quadtree-implementation/#comments</comments>
		<pubDate>Sun, 08 Jul 2012 19:29:26 +0000</pubDate>
		<dc:creator>Adrien</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AGE]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[NME]]></category>

		<guid isPermaLink="false">http://revolugame.com/?p=404</guid>
		<description><![CDATA[<p>What is the QuadTree ?
If we look at the wikipedia page, we can find a small explanation (it&#8217;s the best one I have found so far) :
A quadtree is a tree data structure in which each internal node has exactly four children. Quadtrees are most often used to partition a two dimensional space by  [...]</p><p>The post <a href="http://revolugame.com/age-quadtree-implementation/">AGE &#8211; QuadTree implementation</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></description>
				<content:encoded><![CDATA[<h2>What is the QuadTree ?</h2>
<p>If we look at the <a href="http://en.wikipedia.org/wiki/Quadtree">wikipedia</a> page, we can find a small explanation (it&#8217;s the best one I have found so far) :</p>
<blockquote><p>A quadtree is a tree data structure in which each internal node has exactly four children. Quadtrees are most often used to partition a two dimensional space by recursively subdividing it into four quadrants or regions.</p></blockquote>
<h2>Why would I add it ?</h2>
<p>The first approach to <strong>detect collisions</strong> between entities was to check <strong>for each entity</strong> if it collided with one of the others entities in the world. So you can use this method for a really small game, because the number of tests is not that big. But if you have, for example, a game with 100 entities moving around the screen, which can collide with each other, the number of tests between entities will be 100&#215;100 !! And at least half (probably more) of them are <strong>not necessary</strong>.<br />
The Quadtree allows you to eliminate those unnecessary checks.</p>
<h2>How does it work ?</h2>
<p>Each time an entity is added to the stage, we just have to look into the tree and find where to put it. A node is simply a rectangular zone with entities and other nodes in it.</p>
<p>So basically, any node will be <strong>divided in 4 nodes</strong> if <strong>more than n entities</strong> are <strong>completely contained</strong> within the node. For AGE, I have decided to use n = 2.</p>
<p>Here is a more concrete example :</p>
<p><a href="http://revolugame.com/wp-content/uploads/2012/07/tree0.png"><img src="http://revolugame.com/wp-content/uploads/2012/07/tree0.png" alt="" title="tree0" width="153" height="153" class="aligncenter size-full wp-image-452" /></a></p>
<div style="text-align:center">The world has 1 entity, the entity is added to the root node (depth = 0).</div>
<p>&nbsp;</p>
<p><a href="http://revolugame.com/wp-content/uploads/2012/07/tree1.png"><img src="http://revolugame.com/wp-content/uploads/2012/07/tree1.png" alt="" title="tree1" width="153" height="153" class="aligncenter size-full wp-image-451" /></a></p>
<div style="text-align:center">A second entity is added, so the world has been divided. The first entity (<span style="color:#FF0000">the red one</span>) is pushed down to the top left node, and the <span style="color:#a0e045">second one</span> is pushed down to the top right node (depth = 1).</div>
<p>&nbsp;</p>
<p><a href="http://revolugame.com/wp-content/uploads/2012/07/tree2.png"><img src="http://revolugame.com/wp-content/uploads/2012/07/tree2.png" alt="" title="tree2" width="153" height="153" class="aligncenter size-full wp-image-456" /></a></p>
<div>A third entity is added to the stage. This one is contained in the top left node. This node <strong>has already another entity</strong>, so we just divide this node in 4. Now the first entity (<span style="color:#FF0000">the red one</span>) does not fit entirely in a sub node, so this entity is going to stay on the same node (<strong>top left at depth 1</strong>). But the other entity (<span style="color:#364fd2">the blue one</span>) is pushed down to the <strong>bottom right node at depth 2</strong>. For the <span style="color:#a0e045">last entity</span>, nothing has to change for now.</div>
<p>&nbsp;</p>
<p>Now, our tree <strong>has been set</strong>. Before checking for collisions, we have <strong>to query the tree</strong> to determine which entities are <strong>worth testing for a rectangular zone</strong> (the rectangular zone can correspond to the theoretical position of an entity, to know if we can move it or not). So, the quadtree is going to <strong>return each entity contained in a node that have an intersection with our request zone</strong> (we have to return entities that are not entirely in a sub node too).<br />
<span id="more-404"></span><br />
Here is a simple example: use the arrow keys to move the black entity, and look at the nodes (especially when near the entity at the right of the world) : </p>
<div class="embedswf">
    <div id="swfobj_3">
      
    </div>
</div>
<p>&nbsp;</p>
<p>The post <a href="http://revolugame.com/age-quadtree-implementation/">AGE &#8211; QuadTree implementation</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://revolugame.com/age-quadtree-implementation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>AGE project setup</title>
		<link>http://revolugame.com/age-project-setup/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=age-project-setup</link>
		<comments>http://revolugame.com/age-project-setup/#comments</comments>
		<pubDate>Sun, 01 Jul 2012 13:31:03 +0000</pubDate>
		<dc:creator>Adrien</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[AGE]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[NME]]></category>

		<guid isPermaLink="false">http://revolugame.com/?p=382</guid>
		<description><![CDATA[<p>Since the 0.2 version, you can quickly and easily install AGE in haxelib, just by using the ant task :

git clone https://github.com/po8rewq/AGE.git
ant

For now, you can run the following command to setup a new project :

haxelib run AGE

This will generate a basic structure for your project, with  [...]</p><p>The post <a href="http://revolugame.com/age-project-setup/">AGE project setup</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Since the 0.2 version, you can quickly and easily install <strong>AGE</strong> in haxelib, just by using the ant task :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git clone</span> https:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>po8rewq<span style="color: #000000; font-weight: bold;">/</span>AGE.git
ant</pre></td></tr></table></div>

<p>For now, you can run the following command to setup a new project :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">haxelib run AGE</pre></td></tr></table></div>

<p>This will generate a <strong>basic structure</strong> for your project, with the <strong>nmml</strong> file, and the <a href="http://monodevelop.com/">MonoDevelop</a> &#8211; <a href="http://www.flashdevelop.org/">FlashDevelop</a> project files.</p>
<p>Here is the list of all arguments you can use :</p>
<ul>
<li><strong>-help</strong> : the help screen</li>
<li><strong>-output</strong> : /your/project/directory (default: the current directory)</li>
<li><strong>-name</strong> : Your Project Name</li>
<li><strong>-main</strong> : MainProjectClass (default: Main)</li>
<li><strong>-size</strong> : WIDTH HEIGHT (default: 800&#215;600)</li>
<li><strong>-fps</strong> : FPS (default: 30)</li>
<li><strong>-bgColor</strong> : COLOR (default: 0xCECECE, you can use both 0xFF0000 and #FF0000 syntax)</li>
</ul>
<p class="alert">This tool has only been tested on Linux &#8230;</p>
<p>The post <a href="http://revolugame.com/age-project-setup/">AGE project setup</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://revolugame.com/age-project-setup/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AGE : Another Game Engine</title>
		<link>http://revolugame.com/age-another-game-engine/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=age-another-game-engine</link>
		<comments>http://revolugame.com/age-another-game-engine/#comments</comments>
		<pubDate>Mon, 18 Jun 2012 21:09:29 +0000</pubDate>
		<dc:creator>Adrien</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[AGE]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[NME]]></category>

		<guid isPermaLink="false">http://revolugame.com/?p=332</guid>
		<description><![CDATA[<p>I&#8217;ve tried a lot of game engines since I&#8217;ve started making games. And I&#8217;ve never been completely happy with them&#8230; so I have decided to develop and share my new Haxe/NME game engine.
Why another engine ?
For the past two years I have built game engines, first for AS3, then for Haxe just to learn how  [...]</p><p>The post <a href="http://revolugame.com/age-another-game-engine/">AGE : Another Game Engine</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve tried a lot of game engines since I&#8217;ve started making games. And I&#8217;ve never been completely happy with them&#8230; so I have decided to develop and share my new <strong>Haxe/NME game engine</strong>.</p>
<h2>Why another engine ?</h2>
<p>For the past two years I have built game engines, first for <strong>AS3</strong>, then for <strong>Haxe</strong> just to learn how it works. I have made games with <a href="http://flixel.org" target="_blank">Flixel</a>, <a href="http://flashpunk.net" target="_blank">Flashpunk</a> (for the most known), but each time there is something I am not confortable with (how collisions are handled in Flixel for example). So as they say, if you want something done, it&#8217;s better to do it yourself: that&#8217;s why I decided to create my own game engine, in order to use a tool that&#8217;s best suited for me. Despite the specificities I wanted to add, I tried to keep it as simple and as generic as possible.</p>
<h2>Basic concepts : the behaviors</h2>
<p>Ever since I discovered this <strong>behaviors</strong> concept, it seems that I can&#8217;t do without it! </p>
<p>But what is this ? It&#8217;s a small concept, but it&#8217;s so simple that I don&#8217;t understand why no other game engines (that I am aware of) use it.</p>
<p>For example, you can have a default jump behavior, and if the player catches a power up, you can enable the jet pack behavior :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">class</span> Player <span style="color: #6699cc; font-weight: bold;">extends</span> Entity
<span style="color: #000000;">&#123;</span>
    <span style="color: #6699cc; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _jumpBehavior <span style="color: #339933;">:</span> JumpBehavior<span style="color: #339933;">;</span>
    <span style="color: #6699cc; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _jetpackBehavior <span style="color: #339933;">:</span> JetPackBehavior<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> <span style="color: #6699cc; font-weight: bold;">new</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #6699cc; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        _jumpBehavior <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> JumpBehavior<span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        addBehavior<span style="color: #000000;">&#40;</span>_jumpBehavior<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        _jetpackBehavior <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> JetPackBehavior<span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        addBehavior<span style="color: #000000;">&#40;</span>_jetpackBehavior, <span style="color: #000066; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">override</span> <span style="color: #6699cc; font-weight: bold;">function</span> update<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #6699cc; font-weight: bold;">super</span>.<span style="color: #006633;">update</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #6699cc; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> powerup <span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            _jumpBehavior.<span style="color: #006633;">disable</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
            _jetpackBehavior.<span style="color: #006633;">enable</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>And all the player needs to do is in the <strong>update()</strong> function of the <strong>Behavior Class</strong>.<br />
So simple, and you can add it to any entity you like.</p>
<p>By default, there is two behaviors : <strong>Collisions</strong> and <strong>Movements</strong>.<br />
You can decide not to use them. But if you want collisions and movement, just activate them:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;">solid <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
movable <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Follow the work on <a href="https://github.com/po8rewq/AGE">github</a>.</p>
<p>The post <a href="http://revolugame.com/age-another-game-engine/">AGE : Another Game Engine</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://revolugame.com/age-another-game-engine/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>HxSpriter released</title>
		<link>http://revolugame.com/hxspriter-spriter/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hxspriter-spriter</link>
		<comments>http://revolugame.com/hxspriter-spriter/#comments</comments>
		<pubDate>Tue, 08 May 2012 14:18:27 +0000</pubDate>
		<dc:creator>Adrien</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Flixel]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[HaxePunk]]></category>
		<category><![CDATA[NME]]></category>

		<guid isPermaLink="false">http://revolugame.com/?p=100</guid>
		<description><![CDATA[<p>HxSpriter is the Haxe implementation of the Spriter application and file format.
It&#8217;s a port a the SpriterAS3 lib, but working with NME. It basically lets you use Spriter with your games or applications.
First of all, what&#8217;s Spriter?
Spriter is a powerful animation tool for creating highly detailed  [...]</p><p>The post <a href="http://revolugame.com/hxspriter-spriter/">HxSpriter released</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><strong>HxSpriter</strong> is the <strong>Haxe</strong> implementation of the <a href="http://www.brashmonkey.com/spriter.htm" target="_blank">Spriter application</a> and file format.<br />
It&#8217;s a port a the <a href="http://abeltoy.com/projects/spriterAS3/index.html">SpriterAS3</a> lib, but working with <strong>NME</strong>. It basically lets you use Spriter with your games or applications.</p>
<h2>First of all, what&#8217;s Spriter?</h2>
<blockquote><p>Spriter is a powerful animation tool for creating highly detailed 2d real-time game characters and effects in an intuitive, visual editor. The characters are saved to a format that allows game engines to produce higher quality visuals, while also using less video ram, and requiring less disk space per frame than traditional 2d sprite animation.</p>
<p>Spriter also provides several game specific features like collision boxes, and sound effect triggering, and saves to an open format that will be useable across many different game engines and platforms.</p></blockquote>
<p>Spriter is currently in an <strong>usable beta state</strong>, but it&#8217;s really subject to changes, so the various implementations might stop working from a version to another, and they will need constant updating. The file format may also get incompatible across future versions, and the application may cause some crashes. For these reasons, Spriter is not production ready, but you can test it and play with it if you want.</p>
<h2>How to use it ?</h2>
<p>To use it, just install it from <a href="http://lib.haxe.org/p/HxSpriter">haxelib</a> :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">haxelib <span style="color: #c20cb9; font-weight: bold;">install</span> HxSpriter</pre></td></tr></table></div>

<p>In your NME file, you have to define a sprites directory (just rename the directory where you have all your Spriter&#8217;s animations).</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;assets</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;path/to/the/sprites/directory&quot;</span> <span style="color: #000066;">rename</span>=<span style="color: #ff0000;">&quot;sprites&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>Now, if you want to use the library :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> spriter <span style="color: #339933;">:</span> BitmapSpriter <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> BitmapSpriter<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">'BetaFormatHero.SCML'</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">300</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
spriter.<span style="color: #006633;">playAnimation</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">'idle_healthy'</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
addChild<span style="color: #000000;">&#40;</span>spriter<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Or with the <a href="https://github.com/Beeblerox/HaxeFlixel" target="_blank">Flixel</a> port :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> spriter <span style="color: #339933;">:</span> FlxSpriter <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> FlxSpriter<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">'BetaFormatHero.SCML'</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">300</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
spriter.<span style="color: #006633;">playAnimation</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">'idle_healthy'</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
add<span style="color: #000000;">&#40;</span>spriter<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Or with <a href="http://haxepunk.com/" target="_blank">HaxePunk</a> :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> spriter <span style="color: #339933;">:</span> HxpSpriter <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> HxpSpriter<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">'BetaFormatHero.SCML'</span>, <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">300</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
spriter.<span style="color: #006633;">playAnimation</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">'idle_healthy'</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
addGraphic<span style="color: #000000;">&#40;</span> spriter <span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>You can also checkout the repository : <a href="https://github.com/po8rewq/hxSpriter" target="_blank">https://github.com/po8rewq/hxSpriter</a>.</p>
<p>The post <a href="http://revolugame.com/hxspriter-spriter/">HxSpriter released</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://revolugame.com/hxspriter-spriter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NME &#8211; Premiers pas sous android</title>
		<link>http://revolugame.com/nme-premiers-pas-sous-android/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nme-premiers-pas-sous-android</link>
		<comments>http://revolugame.com/nme-premiers-pas-sous-android/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 13:54:40 +0000</pubDate>
		<dc:creator>Adrien</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Haxe]]></category>
		<category><![CDATA[NME]]></category>

		<guid isPermaLink="false">http://revolugame.com/?p=84</guid>
		<description><![CDATA[<p>La version 3 de NME est enfin disponible sur haxelib !!
Le rêve de tout développeur est en train de se réaliser : developper une application, et la publier sur toutes les plates formes ! C&#8217;est enfin possible grâce à haXe et NME.
Quelques précisions :
Avant d&#8217;aller plus loin, voyons un peu de quoi  [...]</p><p>The post <a href="http://revolugame.com/nme-premiers-pas-sous-android/">NME &#8211; Premiers pas sous android</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>La version 3 de <strong>NME</strong> est enfin disponible sur <strong>haxelib </strong>!!</p>
<p>Le rêve de tout développeur est en train de se réaliser : developper une application, et la publier sur <strong>toutes les plates formes</strong> ! C&#8217;est enfin possible grâce à <strong>haXe </strong>et <strong>NME</strong>.</p>
<h2>Quelques précisions :</h2>
<p>Avant d&#8217;aller plus loin, voyons un peu de quoi il s&#8217;agit. Si vous êtes familié avec <a href="http://www.haxe.org/" target="_blank">haXe</a>, vous ne l&#8217;êtes peut etre pas avec <strong>NME</strong>.</p>
<p><strong>NME </strong>(pour Neko Media Engine) est un <strong>framework open source</strong> permettant de publier une application vers tout type de plate forme (windows, linux, android, ios, et j&#8217;en passe). Ce framework s&#8217;appui sur le langage <strong>haXe</strong>, ce qui permet d&#8217;avoir une syntaxe proche de l&#8217;<strong>Actionscript</strong>. <strong>NME </strong>s&#8217;occupe ensuite de mapper tout ca, et de publier pour la plate forme voulue.</p>
<p>Nous ne nous interresserons pour le moment, qu&#8217;à la plate forme <strong>android</strong>.</p>
<p>Voici un schéma permettant de comprendre le fonctionnement :</p>
<p style="text-align: center;"><a href="http://revolugame.com/wp-content/uploads/2012/05/AndroidFlowChart.png"><img class=" wp-image-85 aligncenter" title="AndroidFlowChart" src="http://revolugame.com/wp-content/uploads/2012/05/AndroidFlowChart.png" alt="" width="650" /></a></p>
<p style="text-align: center;">(source: <a href="http://www.haxenme.org/" target="_blank">www.haxenme.org</a>)</p>
<p>NME va utiliser le compilateur <strong>haxe</strong>, avec la librairie <strong>HXCPP </strong>pour générer les classes <strong>C++</strong>. La compilation va se poursuivre via le <a href="http://developer.android.com/sdk/index.html" target="_blank">SDK et le NDK Android</a>.</p>
<p>Et pour terminer, en passant par une tache <a href="https://ant.apache.org/" target="_blank">Ant</a>, le processus de compilation va se terminer et lancer (si besoin) l&#8217;installation sur le périphérique Android.</p>
<h2><span id="more-84"></span></h2>
<h2>Installation :</h2>
<p>Voici la liste des étapes à suivre pour avoir un environnement de travail fonctionnel. Je suis sous linux, mais sous n&#8217;importe quelle plate forme, l&#8217;approche reste à peu de chose prêt la même.</p>
<p>Tout d&#8217;abord, haxe : télécharger l&#8217;installeur sur le site <a href="http://haxe.org/download">haxe.org</a>, décompresser puis :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">haxelib <span style="color: #c20cb9; font-weight: bold;">install</span> hxcpp
haxelib <span style="color: #c20cb9; font-weight: bold;">install</span> nme
haxelib <span style="color: #c20cb9; font-weight: bold;">install</span> gm2d</pre></td></tr></table></div>

<p>Il nous faut maintenant récuperer le <a href="http://developer.android.com/sdk/index.html" target="_blank">SDK et le NDK android</a> (menu de gauche pour le NDK) :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>dl.google.com<span style="color: #000000; font-weight: bold;">/</span>android<span style="color: #000000; font-weight: bold;">/</span>android-sdk_r12-linux_x86.tgz
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>dl.google.com<span style="color: #000000; font-weight: bold;">/</span>android<span style="color: #000000; font-weight: bold;">/</span>ndk<span style="color: #000000; font-weight: bold;">/</span>android-ndk-r6b-linux-x86.tar.bz2</pre></td></tr></table></div>

<p>Le JDK java :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> openjdk-<span style="color: #000000;">6</span>-jdk</pre></td></tr></table></div>

<p>Et enfin, ant</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> ant1.8</pre></td></tr></table></div>

<p>Une fois que tout est téléchargé/installé, nous devons setter les variables d&#8217;environnements :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">ANDROID_SDK
ANDROID_NDK_ROOT
<span style="color: #007800;">ANDROID_HOST</span>=linux_x86 <span style="color: #7a0874; font-weight: bold;">&#91;</span>linux only<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #007800;">JAVA_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>jvm<span style="color: #000000; font-weight: bold;">/</span>java-1.6.0-openjdk</pre></td></tr></table></div>

<h2>Petite application de test</h2>
<p>Le code :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="haxe" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">package</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">import</span> <span style="color: #006699;">flash.display.Sprite</span><span style="color: #339933;">;</span>
<span style="color: #6699cc; font-weight: bold;">import</span> <span style="color: #006699;">flash.display.StageAlign</span><span style="color: #339933;">;</span>
<span style="color: #6699cc; font-weight: bold;">import</span> <span style="color: #006699;">flash.display.StageScaleMode</span><span style="color: #339933;">;</span>
<span style="color: #6699cc; font-weight: bold;">import</span> <span style="color: #006699;">flash.geom.Rectangle</span><span style="color: #339933;">;</span>
<span style="color: #6699cc; font-weight: bold;">import</span> <span style="color: #006699;">flash.Lib</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #6699cc; font-weight: bold;">class</span> Sample <span style="color: #6699cc; font-weight: bold;">extends</span> Sprite
<span style="color: #000000;">&#123;</span>
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">function</span> <span style="color: #6699cc; font-weight: bold;">new</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #6699cc; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        Lib.<span style="color: #006633;">current</span>.<span style="color: #006633;">stage</span>.<span style="color: #006633;">align</span> <span style="color: #339933;">=</span> StageAlign.<span style="color: #006633;">TOP_LEFT</span><span style="color: #339933;">;</span>
        Lib.<span style="color: #006633;">current</span>.<span style="color: #006633;">stage</span>.<span style="color: #006633;">scaleMode</span> <span style="color: #339933;">=</span> StageScaleMode.<span style="color: #006633;">NO_SCALE</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #6699cc; font-weight: bold;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">'Hello World'</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #6699cc; font-weight: bold;">var</span> rect <span style="color: #339933;">:</span> Sprite <span style="color: #339933;">=</span> <span style="color: #6699cc; font-weight: bold;">new</span> Sprite<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        rect.<span style="color: #006633;">graphics</span>.<span style="color: #006633;">beginFill</span><span style="color: #000000;">&#40;</span>0xFF0000<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        rect.<span style="color: #006633;">graphics</span>.<span style="color: #006633;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">200</span>, <span style="color: #cc66cc;">200</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        rect.<span style="color: #006633;">graphics</span>.<span style="color: #006633;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        addChild<span style="color: #000000;">&#40;</span>rect<span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #6699cc; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">static</span> <span style="color: #6699cc; font-weight: bold;">function</span> main <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        Lib.<span style="color: #006633;">current</span>.<span style="color: #006633;">addChild</span><span style="color: #000000;">&#40;</span> <span style="color: #6699cc; font-weight: bold;">new</span> Sample<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>		
        <span style="color: #330000; font-weight: bold;">#if</span> nme
        Lib.<span style="color: #006633;">current</span>.<span style="color: #006633;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">new</span> nme.<span style="color: #006633;">display</span>.<span style="color: #006633;">FPS</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #330000; font-weight: bold;">#end</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Le fichier de configuration (myConfigFile.nmml) :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;app</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;Sample from revolugame&quot;</span> <span style="color: #000066;">main</span>=<span style="color: #ff0000;">&quot;Sample&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;window</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">orientation</span>=<span style="color: #ff0000;">&quot;landscape&quot;</span> <span style="color: #000066;">fps</span>=<span style="color: #ff0000;">&quot;60&quot;</span> </span>
<span style="color: #009900;">            <span style="color: #000066;">background</span>=<span style="color: #ff0000;">&quot;0xffffff&quot;</span> <span style="color: #000066;">resizeable</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">hardware</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;set</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;BUILD_DIR&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Export&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;classpath</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;src&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;haxelib</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;nme&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;android&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ndll</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;std&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ndll</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;regexp&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ndll</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;zlib&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ndll</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;nme&quot;</span> <span style="color: #000066;">haxelib</span>=<span style="color: #ff0000;">&quot;nme&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Lancer la compilation :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">haxelib run nme <span style="color: #7a0874; font-weight: bold;">test</span> myConfigFile.nmml android</pre></td></tr></table></div>

<p>L&#8217;option <strong>test</strong> correspond à <strong>build </strong>suivi de <strong>run</strong>, mais il est également possible de ne lancer que l&#8217;une de ces options.</p>
<p>Pour tester l&#8217;application en flash, suffit de remplacer <strong>android</strong> par <strong>flash</strong>.</p>
<p>The post <a href="http://revolugame.com/nme-premiers-pas-sous-android/">NME &#8211; Premiers pas sous android</a> appeared first on <a href="http://revolugame.com">RevoluGame</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://revolugame.com/nme-premiers-pas-sous-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
