Skip to content

Commit

Permalink
added SWFTextureAtlasComponent, zoom to the StarlingScene, and rework…
Browse files Browse the repository at this point in the history
…ed the demo to dynamically generate the texture atlas from a swf
  • Loading branch information
zodouglass committed Jun 8, 2012
1 parent b320f5f commit 1baa1a4
Show file tree
Hide file tree
Showing 7 changed files with 794 additions and 36 deletions.
14 changes: 13 additions & 1 deletion examples/PBStarlingDemo/assets/Levels/common.pbelevel
Expand Up @@ -74,7 +74,7 @@
<rotationProperty>@Spatial.rotation</rotationProperty>
<sizeProperty>@Spatial.size</sizeProperty>
</component>

<!--
<component type="com.starling.rendering2D.SpriteSheetRenderer" name="Render">
<textureAtlasComponent componentReference="DudeAtlas"/>
<prefix>dude_</prefix>
Expand All @@ -87,6 +87,18 @@
<positionProperty>@Spatial.position</positionProperty>
<rotationProperty>@Spatial.rotation</rotationProperty>
</component>
-->
<component type="com.starling.rendering2D.SpriteSheetRenderer" name="Render">
<textureAtlasComponent componentReference="DudeSWF" />
<prefix>boy</prefix>
<scene componentReference="Scene"/>
<fps>24</fps>
<positionProperty>@Spatial.position</positionProperty>
<positionOffset>
<x>40</x>
<y>50</y>
</positionOffset>
</component>

<component type="com.starling.animation.AnimatorComponent" name="FrameAnimation">
<animations childType="com.starling.animation.FrameAnimator">
Expand Down
25 changes: 9 additions & 16 deletions examples/PBStarlingDemo/assets/Levels/spriteSheets.pbelevel
@@ -1,18 +1,4 @@
<things version="1">
<entity name="PlatformSpriteSheet">
<component type="com.pblabs.rendering2D.spritesheet.SpriteSheetComponent" name="SpriteSheet">
<image filename="../Assets/Images/platform.png"/>
</component>
</entity>
<entity name="DudeSpriteSheet">
<component type="com.pblabs.rendering2D.spritesheet.SpriteSheetComponent" name="SpriteSheet">
<divider type="com.pblabs.rendering2D.spritesheet.CellCountDivider">
<xCount>8</xCount>
<yCount>8</yCount>
</divider>
<image filename="../Assets/Images/mannequin.png"/>
</component>
</entity>

<entity name="DudeAtlas">
<component type="com.starling.rendering2D.TextureAtlasComponent" name="TextureAtlas">
Expand All @@ -27,10 +13,17 @@
</component>
</entity>

<entity name="DudeSWF">
<component type="com.starling.rendering2D.SWFTextureAtlasComponent" name="TextureAtlas">
<swf filename="../assets/sample_for_atlas.swf" />
<movieClipClassName>SheetMC</movieClipClassName>
<scaleFactor>0.5</scaleFactor>
</component>
</entity>

<group name="SpriteSheets">
<objectReference name="DudeSWF"/>
<objectReference name="DudeAtlas"/>
<objectReference name="DudeSpriteSheet"/>
<objectReference name="PlatformSpriteSheet"/>
<objectReference name="PlatformTexture"/>
</group>
</things>
1 change: 1 addition & 0 deletions examples/PBStarlingDemo/src/PBStarlingDemo.as
Expand Up @@ -64,6 +64,7 @@ package
PBE.registerType(SpriteSheetRenderer );
PBE.registerType(AnimatorComponent);
PBE.registerType(FrameAnimator);
PBE.registerType(SWFTextureAtlasComponent);



Expand Down
28 changes: 28 additions & 0 deletions src/com/starling/rendering2D/DisplayObjectRenderer.as
Expand Up @@ -55,6 +55,12 @@ package com.starling.rendering2D
*/
public var scaleProperty:PropertyReference;

/**
* If set, alpha is gotten from this property every frame.
*/
public var alphaProperty:PropertyReference;


/**
* if set this to false, positions will be handeled with numbers insteed of integers
* makes slow movement smoother for example
Expand All @@ -78,6 +84,7 @@ package com.starling.rendering2D
protected var _positionOffset:Point = new Point();
protected var _registrationPoint:Point = new Point();
protected var _touchable:Boolean = false;
protected var _visible:Boolean = false;

public function get displayObject():DisplayObject
{
Expand Down Expand Up @@ -166,6 +173,12 @@ package com.starling.rendering2D
{
this.scale = scale;
}

//alpha
if ( alphaProperty != null )
{
this.alpha = owner.getProperty(alphaProperty) as Number;
}


// Rotation.
Expand Down Expand Up @@ -369,6 +382,21 @@ package com.starling.rendering2D
_transformDirty = true;
}

public function get visible():Boolean
{
return _visible;
}

public function set visible(value:Boolean):void
{
if ( _visible != value )
{
_visible = value;
alpha = _visible ? 1 : 0;
}

}


/**
* Rotation offset applied to the child DisplayObject. Used if, for instance,
Expand Down
2 changes: 1 addition & 1 deletion src/com/starling/rendering2D/MovieClipRenderer.as
Expand Up @@ -3,7 +3,7 @@ package com.starling.rendering2D
import com.pblabs.engine.serialization.TypeUtility;
import flash.display.MovieClip;
/**
*
* @deprecated Use SpriteSheetRenderer with a SWFTextureAtlasComponent
*/
public class MovieClipRenderer extends SpriteSheetRenderer
{
Expand Down

3 comments on commit 1baa1a4

@Udderpunch
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you verify that the example still works after this release please? I believe you might have missed some files. Most notably the Dude.swf. Also I can't get the camera to work with this build. The platform images render, but don't move correctly with the camera.

@zodouglass
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok update to the latest build. Looks like I forgot to add the dude swf file. Sorry about that...i've been using my game prototype to test and havent had a look at the Demo for a while. I believe the camera issue was because the dude renderer was not being displayed properly, so the camera had nothing to track.
Let me know if you have any other issues.

@Udderpunch
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that was it. Thanks man :)

Please sign in to comment.