Skip to content

Instantly share code, notes, and snippets.

@troygilbert
Created April 18, 2010 16:44
Show Gist options
  • Save troygilbert/370351 to your computer and use it in GitHub Desktop.
Save troygilbert/370351 to your computer and use it in GitHub Desktop.
ResourceLibrary.mxml
<!-- The root of the XML needs to support namespaces that map to packages. -->
<mb:ResourceLibrary
xmlns:mb="com.mockingbirdgames.document.*"
xmlns:tweaks="com.mockingbirdgames.document.tweaks.*"
xmlns:behaviors="com.playmockingbird.behaviors.*"
>
<!-- We use shorthand for setting the contents of a child element. -->
<!-- Instead of: <mb:SpriteCollection id="sprites"/> -->
<mb:sprites>
<mb:Sprite id="critter" width="64" height="64" source="assets/critter.png">
<mb:Animation id="idle" frames="0,1,2,3,4,5,4,3,2,1" fps="15"/>
</mb:Sprite>
</mb:sprites>
<mb:behaviors>
<behaviors:MoveLeftRight id="moveLeftRight">
<!-- These derived tweak classes basically just do type-checking for the UI. -->
<tweaks:Slider id="speed" value="245" min="0" max="500" snap="5"/>
<tweaks:Slider id="traction" value="4.5" min="0" max="10" snap="0.5"/>
</behaviors:Vehicle>
<behaviors:Collectable id="collectable"/>
<behaviors:DisappearOnContact id="disappearOnContact">
<tweaks:Slider id="delay" value="2" min="0" max="10" snap="0.5"/>
</behaviors:DisappearOnContact>
</mb:behaviors>
<mb:objects>
<mb:Object id="player" collidable="true" solid="true">
<mb:behaviors>
<!-- This can be untyped because it's a reference. -->
<mb:Behavior ref="moveLeftRight"/>
</mb:behaviors>
<mb:tweaks>
<!-- This can be an untyped Tweak because a UI is generated from the behavior resource. -->
<!-- This tweak is only used as a value. -->
<tweaks:Tweak id="speed">500</tweaks:Tweak>
</mb:tweaks>
</mb:Object>
</mb:objects>
</mb:ResourceLibrary>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment