Skip to content
This repository
Browse code

Merge pull request #49 from johanp/dev

0.4.3 complete
  • Loading branch information...
commit 4fed0dbe69a936b39230d1115093dad75fff431c 2 parents 0dd8eff + 3364cf1
Johan Peitz authored

Showing 44 changed files with 846 additions and 373 deletions. Show diff stats Hide diff stats

  1. +24 0 CHANGELOG
  2. +2 0  README.md
  3. +4 4 examples/ExampleLauncher.as
  4. +3 2 examples/MenuScene.as
  5. +0 164 examples/assets/AssetFactory.as
  6. +4 2 examples/benchmark/BenchmarkExampleScene.as
  7. +13 2 examples/collision/CollisionExampleScene.as
  8. +13 10 examples/collision/VisualCollisionEntity.as
  9. +2 2 examples/emitter/EmittersExampleScene.as
  10. +8 5 examples/platformer/BadPickup.as
  11. +9 4 examples/platformer/GoodPickup.as
  12. +5 3 examples/platformer/PlatformerScene.as
  13. +20 11 examples/platformer/PlatformerTitleScene.as
  14. +25 20 examples/platformer/Player.as
  15. +3 2 examples/platformer/TileMap.as
  16. +71 0 examples/replay/ReplayEntity.as
  17. +49 0 examples/replay/ReplayExampleScene.as
  18. +3 2 examples/sound/SoundExampleScene.as
  19. +4 2 examples/sound/SoundMaker.as
  20. +11 5 examples/spritesheet/SpriteSheetExampleScene.as
  21. +10 3 examples/text/TextExampleScene.as
  22. +4 2 examples/transform/TransformExampleScene.as
  23. +10 5 pixelizer/Pixelizer.as
  24. +3 3 pixelizer/PxEngine.as
  25. +0 3  pixelizer/components/collision/PxBoxColliderComponent.as
  26. +2 1  pixelizer/components/collision/PxBoxColliderRenderComponent.as
  27. +16 16 pixelizer/components/collision/PxColliderComponent.as
  28. +5 4 pixelizer/components/collision/PxGridColliderComponent.as
  29. +39 16 pixelizer/components/render/PxAnimationComponent.as
  30. +7 6 pixelizer/components/render/PxBlitRenderComponent.as
  31. +18 2 pixelizer/components/render/PxTextFieldComponent.as
  32. +3 9 pixelizer/components/render/PxTileMapComponent.as
  33. +1 1  pixelizer/physics/PxCollisionManager.as
  34. +16 7 pixelizer/physics/PxCollisionSolver.as
  35. +4 4 pixelizer/prefabs/gui/PxGUIButton.as
  36. +38 1 pixelizer/prefabs/logo/PxLogoEntity.as
  37. +0 24 pixelizer/render/PxBitmapFont.as
  38. +2 1  pixelizer/render/PxDefaultFontGenerator.as
  39. +11 24 pixelizer/render/PxSpriteSheet.as
  40. +12 1 pixelizer/sound/PxSoundEntity.as
  41. +144 0 pixelizer/utils/PxBase64.as
  42. +72 0 pixelizer/utils/PxInputPost.as
  43. +120 0 pixelizer/utils/PxInputSequence.as
  44. +36 0 pixelizer/utils/PxRepository.as
24 CHANGELOG
... ... @@ -1,5 +1,29 @@
1 1 CHANGELOG
2 2
  3 +2012-05-13, 0.4.3, "the squasher of bugs"
  4 +* fixed underflow bug in collision detection code
  5 +* fixed broken visibility control on tilemaps
  6 +* fixed gotoAndStop in animation component to work before render component is detected
  7 +* minor changes to the collision example
  8 +* removed default values on grid collider construction
  9 +* added NO_FLIP to Pixelizer constants
  10 +* added possibility to horizontally flip movieclip pre rendering
  11 +* fixed bug that caused non animated animations not to flip when needed
  12 +* fixed box collider not to collide with grids and other boxes by default
  13 +* fixed to that animation component doesn't crash if animation not found
  14 +* remove store and fetch functions from PxSpriteSheet and PxBitmapFont
  15 +* added PxRepository for centralized storage
  16 +* renamed functions for handling collision layers in in PxColliderComponent
  17 +* added shadow offset to PxTextComponent
  18 +* added "POWERED BY" text to logo
  19 +* fixed bug that caused jump through floors to sometimes pop entities up to their level
  20 +* added basic input recording and playback
  21 +* fixed bug that caused global sounds to be unmutable
  22 +* added version number to PxLogoEntity
  23 +* added simple record/replay example
  24 +* removed AssetFactory in order to make examples easier to understand
  25 +
  26 +
3 27 2012-03-31, 0.4.2, "the fixer"
4 28 * fixed so that scaling propagates to nested entities
5 29 * fixed so that scaling affects render position
2  README.md
Source Rendered
@@ -14,12 +14,14 @@ Features:
14 14 * automated collision detection and response
15 15 * spritesheets, animations and tilemaps
16 16 * prerendering of movieclips
  17 + * recording and replaying of input streams
17 18 * automatic panning and volume of moving sounds
18 19 * exact mouse and keyboard input
19 20 * fancy text rendering
20 21 * handy math and string routines
21 22 * effective object pools
22 23 * useful logging
  24 + * persistent storage to lower memory foot print
23 25 * and much more
24 26
25 27
8 examples/ExampleLauncher.as
... ... @@ -1,5 +1,7 @@
1 1 package examples {
2 2 import flash.display.Sprite;
  3 + import flash.text.TextField;
  4 + import flash.text.TextFieldAutoSize;
3 5 import pixelizer.Pixelizer;
4 6 import pixelizer.PxEngine;
5 7
@@ -11,15 +13,13 @@ package examples {
11 13 public class ExampleLauncher extends Sprite {
12 14
13 15 public function ExampleLauncher() {
  16 +
14 17 var engine : PxEngine = new PxEngine( 320, 240, 2 );
15 18 addChild( engine );
16   -
17   - engine.showPerformance = true;
  19 + // engine.showPerformance = true;
18 20 // engine.pauseOnFocusLost = false;
19 21
20 22 engine.pushScene( new MenuScene() );
21   -
22   -
23 23 }
24 24
25 25 }
5 examples/MenuScene.as
... ... @@ -1,5 +1,4 @@
1 1 package examples {
2   - import examples.assets.AssetFactory;
3 2 import examples.benchmark.BenchmarkExampleScene;
4 3 import examples.collision.CollisionExampleScene;
5 4 import examples.emitter.EmittersExampleScene;
@@ -7,6 +6,7 @@ package examples {
7 6 import examples.input.InputExampleScene;
8 7 import examples.nesting.NestingExampleScene;
9 8 import examples.platformer.PlatformerTitleScene;
  9 + import examples.replay.ReplayExampleScene;
10 10 import examples.sound.SoundExampleScene;
11 11 import examples.spritesheet.SpriteSheetExampleScene;
12 12 import examples.text.TextExampleScene;
@@ -42,6 +42,7 @@ package examples {
42 42 _examples.push({ lbl: "Playing Sounds", cls: SoundExampleScene } );
43 43 _examples.push({ lbl: "Collisions", cls: CollisionExampleScene } );
44 44 _examples.push({ lbl: "Emitters", cls: EmittersExampleScene } );
  45 + _examples.push({ lbl: "Replays", cls: ReplayExampleScene } );
45 46 _examples.push({ lbl: "Platform Game", cls: PlatformerTitleScene } );
46 47 _examples.push({ lbl: "Benchmark", cls: BenchmarkExampleScene } );
47 48
@@ -65,7 +66,7 @@ package examples {
65 66 }
66 67 }
67 68
68   - _clock = addEntity( new PxTextFieldEntity( "", Pixelizer.COLOR_GRAY ) ) as PxTextFieldEntity;
  69 + _clock = addEntity( new PxTextFieldEntity( "", Pixelizer.COLOR_LIGHT_GRAY ) ) as PxTextFieldEntity;
69 70 _clock.transform.setPosition( 10, 220 );
70 71 }
71 72
164 examples/assets/AssetFactory.as
... ... @@ -1,164 +0,0 @@
1   -package examples.assets {
2   - import flash.display.BitmapData;
3   - import flash.display.MovieClip;
4   - import flash.media.Sound;
5   - import pixelizer.render.PxBitmapFont;
6   -
7   - /**
8   - * A nice place to store all bitmap assets so they're only instanciated oncel
9   - * @author Johan Peitz
10   - */
11   - public class AssetFactory {
12   -
13   - [Embed( source="sheep.mp3" )]
14   - private static var sheepCls : Class;
15   - private static var sheep : Sound = null;
16   -
17   - public static function get sheepSound() : Sound {
18   - if ( sheep == null ) {
19   - sheep = new sheepCls();
20   - }
21   -
22   - return sheep;
23   - }
24   -
25   - [Embed( source="bird_song.mp3" )]
26   - private static var birdCls : Class;
27   - private static var bird : Sound = null;
28   -
29   - public static function get birdSound() : Sound {
30   - if ( bird == null ) {
31   - bird = new birdCls();
32   - }
33   -
34   - return bird;
35   - }
36   -
37   - [Embed( source="heart.mp3" )]
38   - private static var heartCls : Class;
39   - private static var heart : Sound = null;
40   -
41   - public static function get heartSound() : Sound {
42   - if ( heart == null ) {
43   - heart = new heartCls();
44   - }
45   -
46   - return heart;
47   - }
48   -
49   - [Embed( source="explosion.mp3" )]
50   - private static var explosionCls : Class;
51   - private static var explosion : Sound = null;
52   -
53   - public static function get explosionSound() : Sound {
54   - if ( explosion == null ) {
55   - explosion = new explosionCls();
56   - }
57   -
58   - return explosion;
59   - }
60   -
61   - [Embed( source="jump.mp3" )]
62   - private static var jumpCls : Class;
63   - private static var jump : Sound = null;
64   -
65   - public static function get jumpSound() : Sound {
66   - if ( jump == null ) {
67   - jump = new jumpCls();
68   - }
69   -
70   - return jump;
71   - }
72   -
73   - [Embed( source="music_loop.mp3" )]
74   - private static var musicCls : Class;
75   - private static var music : Sound = null;
76   -
77   - public static function get musicSound() : Sound {
78   - if ( music == null ) {
79   - music = new musicCls();
80   - }
81   -
82   - return music;
83   - }
84   -
85   - [Embed( source="tiles.png" )]
86   - private static var tilesCls : Class;
87   - private static var tilesBitmapData : BitmapData = null;
88   -
89   - public static function get tiles() : BitmapData {
90   - if ( tilesBitmapData == null ) {
91   - tilesBitmapData = new tilesCls().bitmapData;
92   - }
93   -
94   - return tilesBitmapData;
95   - }
96   -
97   - [Embed( source="player.png" )]
98   - private static var playerCls : Class;
99   - private static var playerBitmapData : BitmapData = null;
100   -
101   - public static function get player() : BitmapData {
102   - if ( playerBitmapData == null ) {
103   - playerBitmapData = new playerCls().bitmapData;
104   - }
105   -
106   - return playerBitmapData;
107   - }
108   -
109   - [Embed( source="pickups.png" )]
110   - private static var pickupsCls : Class;
111   - private static var pickupsBitmapData : BitmapData = null;
112   -
113   - public static function get pickups() : BitmapData {
114   - if ( pickupsBitmapData == null ) {
115   - pickupsBitmapData = new pickupsCls().bitmapData;
116   - }
117   -
118   - return pickupsBitmapData;
119   - }
120   -
121   - [Embed( source="box.png" )]
122   - private static var boxCls : Class;
123   - private static var boxBitmapData : BitmapData = null;
124   -
125   - public static function get box() : BitmapData {
126   - if ( boxBitmapData == null ) {
127   - boxBitmapData = new boxCls().bitmapData;
128   - }
129   -
130   - return boxBitmapData;
131   - }
132   -
133   - [Embed( source="round_font.png" )]
134   - private static var rfCls : Class;
135   - private static var rfBitmapData : BitmapData = null;
136   - private static var rfFont : PxBitmapFont = null;
137   -
138   - public static function get roundFont() : PxBitmapFont {
139   - if ( rfFont == null ) {
140   - if ( rfBitmapData == null ) {
141   - rfBitmapData = new rfCls().bitmapData;
142   - }
143   - var letters : String = " !\"#$%&'()*+,-./" + "0123456789:;<=>?" + "@ABCDEFGHIJKLMNO" + "PQRSTUVWXYZ[}]^_" + "'abcdefghijklmno" + "pqrstuvwxyz{|}~\\";
144   - rfFont = new PxBitmapFont( rfBitmapData, letters );
145   - }
146   -
147   - return rfFont;
148   - }
149   -
150   - [Embed( source="animation.swf",symbol="animation" )]
151   - private static var mcClass : Class;
152   - private static var mcInstance : MovieClip = null;
153   -
154   - public static function get mc() : MovieClip {
155   - if ( mcInstance == null ) {
156   - mcInstance = new mcClass();
157   - }
158   -
159   - return mcInstance;
160   - }
161   -
162   - }
163   -
164   -}
6 examples/benchmark/BenchmarkExampleScene.as
... ... @@ -1,5 +1,4 @@
1 1 package examples.benchmark {
2   - import examples.assets.AssetFactory;
3 2 import examples.collision.CollisionExampleScene;
4 3 import examples.emitter.EmittersExampleScene;
5 4 import examples.input.InputExampleScene;
@@ -20,6 +19,9 @@ package examples.benchmark {
20 19
21 20 public class BenchmarkExampleScene extends PxScene {
22 21
  22 + [Embed( source="../assets/pickups.png" )]
  23 + private static var pickupsCls : Class;
  24 +
23 25 private var _testEntities : Array = [];
24 26 private var _infoText : PxTextFieldEntity;
25 27 private var _mode : int = 0;
@@ -29,7 +31,7 @@ package examples.benchmark {
29 31 backgroundColor = Pixelizer.COLOR_WHITE;
30 32
31 33 // image to use
32   - var bd : BitmapData = AssetFactory.pickups;
  34 + var bd : BitmapData = new pickupsCls().bitmapData;
33 35
34 36 // position examples
35 37 for ( var i : int = 0; i < 500; i++ ) {
15 examples/collision/CollisionExampleScene.as
... ... @@ -1,8 +1,11 @@
1 1 package examples.collision {
2 2 import flash.display.Bitmap;
3 3 import flash.display.BitmapData;
  4 + import pixelizer.components.collision.PxBoxColliderComponent;
  5 + import pixelizer.components.collision.PxBoxColliderRenderComponent;
4 6 import pixelizer.components.collision.PxGridColliderComponent;
5 7 import pixelizer.components.PxBodyComponent;
  8 + import pixelizer.components.render.PxBlitRenderComponent;
6 9 import pixelizer.components.render.PxTileMapComponent;
7 10 import pixelizer.Pixelizer;
8 11 import pixelizer.PxEntity;
@@ -42,7 +45,7 @@ package examples.collision {
42 45 gc.setCell( 5, 4, 1 );
43 46 gc.setCell( 3, 6, 1 );
44 47
45   - var tiles : PxEntity = addEntity( new PxEntity( 40, 40 ) );
  48 + var tiles : PxEntity = addEntity( new PxEntity( 200, 60 ) );
46 49 tiles.addComponent( tc );
47 50 tiles.addComponent( gc );
48 51
@@ -50,11 +53,19 @@ package examples.collision {
50 53 _controllableEntity.transform.setPosition( 160, 120 );
51 54
52 55 // some things to collide with
53   - for ( var i : int = 0; i < 40; i++ ) {
  56 + for ( var i : int = 0; i < 10; i++ ) {
54 57 var e : VisualCollisionEntity = new VisualCollisionEntity( PxMath.randomBoolean() );
55 58 e.transform.setPosition( PxMath.randomInt( 40, 264 ), PxMath.randomInt( 40, 184 ) );
56 59 addEntity( e );
57 60 }
  61 +
  62 + // big area to collide with
  63 + var entity : PxEntity = addEntity( new PxEntity( 40, 100 ) );
  64 + entity.addComponent( new PxBlitRenderComponent( PxImageUtil.createRect( 20, 20 ) ) );
  65 + var bc : PxBoxColliderComponent = entity.addComponent( new PxBoxColliderComponent( 40, 40, false ) ) as PxBoxColliderComponent;
  66 + bc.collisionBox.offsetX = 10;
  67 + bc.collisionBox.offsetY = 10;
  68 + entity.addComponent( new PxBoxColliderRenderComponent() );
58 69
59 70 }
60 71
23 examples/collision/VisualCollisionEntity.as
@@ -10,6 +10,7 @@ package examples.collision {
10 10 import pixelizer.PxEntity;
11 11 import pixelizer.render.PxSpriteSheet;
12 12 import pixelizer.utils.PxImageUtil;
  13 + import pixelizer.utils.PxLog;
13 14 import pixelizer.utils.PxMath;
14 15
15 16 public class VisualCollisionEntity extends PxEntity {
@@ -30,7 +31,15 @@ package examples.collision {
30 31 addComponent( new PxBodyComponent( 0 ) );
31 32
32 33 var collider : PxBoxColliderComponent = new PxBoxColliderComponent( 16, 16, pSolid );
33   - collider.registerCallbacks( onCollisionStart, onCollisionOngoing, onCollisionEnd );
  34 + // live in box layer
  35 + collider.addToCollisionLayer( 2 );
  36 + // collide with other boxes
  37 + collider.enableCollisionWithCollisionLayer( 2 );
  38 + // collide with grid
  39 + collider.enableCollisionWithCollisionLayer( Pixelizer.COLLISION_LAYER_GRID );
  40 +
  41 +
  42 + collider.registerCallbacks( onCollisionStart, null, onCollisionEnd );
34 43 addComponent( collider );
35 44 }
36 45
@@ -39,23 +48,17 @@ package examples.collision {
39 48 super.dispose();
40 49 }
41 50
42   - /*
43   - override public function update( pDT : Number ) : void {
44   -
45   - super.update( pDT );
46   - }
47   - */
48 51
49 52 private function onCollisionStart( pCollisionData : PxCollisionData ) : void {
50 53 _animComp.gotoAndStop( 1 );
  54 + PxLog.log( "start " + pCollisionData.otherCollider, this );
51 55 }
52 56
53   - private function onCollisionOngoing( pCollisionData : PxCollisionData ) : void {
54   - _animComp.gotoAndStop( 1 );
55   - }
56 57
57 58 private function onCollisionEnd( pCollisionData : PxCollisionData ) : void {
58 59 _animComp.gotoAndStop( 0 );
  60 + PxLog.log( "end " + pCollisionData.otherCollider, this );
  61 +
59 62 }
60 63 }
61 64
4 examples/emitter/EmittersExampleScene.as
@@ -25,7 +25,7 @@ package examples.emitter {
25 25 emitterComp.setEmitAngleRange( -PxMath.PI * 3 / 4, -PxMath.PI * 1 / 4 );
26 26
27 27 emitter = new PxEntity();
28   - emitter.addComponent( new PxBlitRenderComponent( PxImageUtil.createCircle( 8, Pixelizer.COLOR_GRAY ) ) );
  28 + emitter.addComponent( new PxBlitRenderComponent( PxImageUtil.createCircle( 8, Pixelizer.COLOR_LIGHT_GRAY ) ) );
29 29 emitter.addComponent( emitterComp );
30 30 emitter.transform.setPosition( 80, 120 );
31 31 addEntity( emitter );
@@ -39,7 +39,7 @@ package examples.emitter {
39 39 emitterComp.setEmitAngleRange( 0, PxMath.TWO_PI );
40 40
41 41 emitter = new PxEntity();
42   - emitter.addComponent( new PxBlitRenderComponent( PxImageUtil.createCircle( 8, Pixelizer.COLOR_GRAY ) ) );
  42 + emitter.addComponent( new PxBlitRenderComponent( PxImageUtil.createCircle( 8, Pixelizer.COLOR_LIGHT_GRAY ) ) );
43 43 emitter.addComponent( emitterComp );
44 44 emitter.transform.setPosition( 240, 120 );
45 45 addEntity( emitter );
13 examples/platformer/BadPickup.as
... ... @@ -1,5 +1,4 @@
1 1 package examples.platformer {
2   - import examples.assets.AssetFactory;
3 2 import pixelizer.components.collision.PxBoxColliderComponent;
4 3 import pixelizer.components.PxBodyComponent;
5 4 import pixelizer.components.render.PxAnimationComponent;
@@ -9,25 +8,29 @@ package examples.platformer {
9 8 import pixelizer.PxEntity;
10 9 import pixelizer.render.PxSpriteSheet;
11 10 import pixelizer.sound.PxSoundManager;
  11 + import pixelizer.utils.PxRepository;
12 12
13 13 /**
14 14 * ...
15 15 * @author Johan Peitz
16 16 */
17 17 public class BadPickup extends PxActorEntity {
  18 + [Embed( source="../assets/explosion.mp3" )]
  19 + private static var explosionSoundCls : Class;
  20 +
18 21
19 22 public function BadPickup() {
20 23 super();
21 24
22 25 // anim comp, to handle animations
23   - animComp.spriteSheet = PxSpriteSheet.fetch( "pickups" );
  26 + animComp.spriteSheet = PxRepository.fetch( "pickups" );
24 27 animComp.gotoAndPlay( "bad" );
25 28
26 29 bodyComp.mass = 0;
27 30
28 31 boxColliderComp.setSize( 16, 16 );
29   - boxColliderComp.solid = false;
30   - boxColliderComp.collisionLayerMask = 0;
  32 + boxColliderComp.solid = true;
  33 + boxColliderComp.addToCollisionLayer( 1 ); // pickups
31 34 boxColliderComp.registerCallbacks( onCollisionStart );
32 35
33 36 }
@@ -69,7 +72,7 @@ package examples.platformer {
69 72 parent.addEntity( p );
70 73 }
71 74
72   - PxSoundManager.play( AssetFactory.explosionSound, transform.position );
  75 + PxSoundManager.play( new explosionSoundCls(), transform.position );
73 76
74 77 destroyIn( 0 );
75 78 }
13 examples/platformer/GoodPickup.as
... ... @@ -1,5 +1,4 @@
1 1 package examples.platformer {
2   - import examples.assets.AssetFactory;
3 2 import flash.geom.Point;
4 3 import pixelizer.components.collision.PxBoxColliderComponent;
5 4 import pixelizer.components.PxBodyComponent;
@@ -11,6 +10,7 @@ package examples.platformer {
11 10 import pixelizer.render.PxSpriteSheet;
12 11 import pixelizer.sound.PxSoundManager;
13 12 import pixelizer.utils.PxMath;
  13 + import pixelizer.utils.PxRepository;
14 14
15 15 /**
16 16 * ...
@@ -18,10 +18,13 @@ package examples.platformer {
18 18 */
19 19 public class GoodPickup extends PxActorEntity {
20 20
  21 + [Embed( source="../assets/heart.mp3" )]
  22 + private static var heartSoundCls : Class;
  23 +
21 24 public function GoodPickup() {
22 25 super();
23 26
24   - animComp.spriteSheet = PxSpriteSheet.fetch( "pickups" );
  27 + animComp.spriteSheet = PxRepository.fetch( "pickups" );
25 28 animComp.gotoAndPlay( "good" );
26 29
27 30 // the body handles velocities
@@ -29,7 +32,7 @@ package examples.platformer {
29 32
30 33 boxColliderComp.setSize( 16, 16 );
31 34 boxColliderComp.solid = false;
32   - boxColliderComp.collisionLayerMask = 0;
  35 + boxColliderComp.addToCollisionLayer( 1 );// pick ups
33 36 boxColliderComp.registerCallbacks( onCollisionStart );
34 37
35 38 }
@@ -52,7 +55,7 @@ package examples.platformer {
52 55 var a : Number;
53 56 var colors : Array = [ 0xFF5750, 0xCC2E29, 0xFFA9A6, 0xFFFFFF ];
54 57
55   - PxSoundManager.play( AssetFactory.heartSound, transform.position );
  58 + PxSoundManager.play( new heartSoundCls(), transform.position );
56 59
57 60 // emit particles
58 61 for ( var i : int = 0; i < 50; i++ ) {
@@ -84,6 +87,8 @@ package examples.platformer {
84 87 f = 10000 / ( dist * dist );
85 88 g.addVelocity( -f * PxMath.cos( a ), -f * Math.sin( a ) );
86 89 }
  90 +
  91 + destroyIn( 0 );
87 92 }
88 93
89 94 public function addVelocity( pVX : Number, pVY : Number ) : void {
8 examples/platformer/PlatformerScene.as
... ... @@ -1,5 +1,4 @@
1 1 package examples.platformer {
2   - import examples.assets.AssetFactory;
3 2 import flash.geom.Point;
4 3 import pixelizer.components.collision.PxBoxColliderComponent;
5 4 import pixelizer.components.collision.PxBoxColliderRenderComponent;
@@ -26,6 +25,10 @@ package examples.platformer {
26 25 [Embed( source='../assets/platformer.oel',mimeType="application/octet-stream" )]
27 26 public static const LevelData : Class;
28 27
  28 + [Embed( source="../assets/music_loop.mp3" )]
  29 + private static var musicSoundCls : Class;
  30 +
  31 +
29 32 // layers to better control where things are drawn
30 33 private var _bgLayer : PxEntity;
31 34 private var _actionLayer : PxEntity;
@@ -55,7 +58,6 @@ package examples.platformer {
55 58
56 59 // create a player, and add it to the action layer
57 60 _player = new Player();
58   - _player.reset();
59 61 _actionLayer.addEntity( _player );
60 62
61 63 // each scene has a camera, set it to track the player
@@ -74,7 +76,7 @@ package examples.platformer {
74 76 }
75 77
76 78 // play music
77   - addEntity( new PxSoundEntity( AssetFactory.musicSound, null, true ) );
  79 + addEntity( new PxSoundEntity( new musicSoundCls(), null, true ) );
78 80 }
79 81
80 82 override public function dispose() : void {
31 examples/platformer/PlatformerTitleScene.as
... ... @@ -1,5 +1,4 @@
1 1 package examples.platformer {
2   - import examples.assets.AssetFactory;
3 2 import pixelizer.components.render.PxTextFieldComponent;
4 3 import pixelizer.Pixelizer;
5 4 import pixelizer.prefabs.gui.PxTextFieldEntity;
@@ -8,23 +7,33 @@ package examples.platformer {
8 7 import pixelizer.render.PxAnimation;
9 8 import pixelizer.render.PxBlitRenderer;
10 9 import pixelizer.render.PxSpriteSheet;
  10 + import pixelizer.utils.PxRepository;
11 11
12 12 public class PlatformerTitleScene extends PxScene {
  13 +
  14 + [Embed( source="../assets/tiles.png" )]
  15 + private static var tilesBitmapCls : Class;
  16 +
  17 + [Embed( source="../assets/player.png" )]
  18 + private static var playerBitmapCls : Class;
  19 +
  20 + [Embed( source="../assets/pickups.png" )]
  21 + private static var pickupsBitmapCls : Class;
13 22
14 23 public function PlatformerTitleScene() {
15   - if ( PxSpriteSheet.fetch( "tiles" ) == null ) {
16   - PxSpriteSheet.store( "tiles", new PxSpriteSheet() ).addFramesFromBitmapData( AssetFactory.tiles, 16, 16 );
17   - PxSpriteSheet.store( "player", new PxSpriteSheet() ).addFramesFromBitmapData( AssetFactory.player, 16, 16, Pixelizer.H_FLIP );
18   - PxSpriteSheet.store( "pickups", new PxSpriteSheet() ).addFramesFromBitmapData( AssetFactory.pickups, 16, 16, Pixelizer.H_FLIP );
  24 + if ( PxRepository.fetch( "tiles" ) == null ) {
  25 + PxRepository.store( "tiles", new PxSpriteSheet() ).addFramesFromBitmapData( new tilesBitmapCls().bitmapData, 16, 16 );
  26 + PxRepository.store( "player", new PxSpriteSheet() ).addFramesFromBitmapData( new playerBitmapCls().bitmapData, 16, 16, Pixelizer.H_FLIP );
  27 + PxRepository.store( "pickups", new PxSpriteSheet() ).addFramesFromBitmapData( new pickupsBitmapCls().bitmapData, 16, 16, Pixelizer.H_FLIP );
19 28
20 29 // set up animations
21   - PxSpriteSheet.fetch( "player" ).addAnimation( new PxAnimation( "idle", [ 0 ] ) );
22   - PxSpriteSheet.fetch( "player" ).addAnimation( new PxAnimation( "walk", [ 1, 0 ], 10, PxAnimation.ANIM_LOOP ) );
23   - PxSpriteSheet.fetch( "player" ).addAnimation( new PxAnimation( "jump", [ 2 ] ) );
24   - PxSpriteSheet.fetch( "player" ).addAnimation( new PxAnimation( "die", [ 3, 4 ], 5, PxAnimation.ANIM_LOOP ) );
  30 + PxRepository.fetch( "player" ).addAnimation( new PxAnimation( "idle", [ 0 ] ) );
  31 + PxRepository.fetch( "player" ).addAnimation( new PxAnimation( "walk", [ 1, 0 ], 10, PxAnimation.ANIM_LOOP ) );
  32 + PxRepository.fetch( "player" ).addAnimation( new PxAnimation( "jump", [ 2 ] ) );
  33 + PxRepository.fetch( "player" ).addAnimation( new PxAnimation( "die", [ 3, 4 ], 5, PxAnimation.ANIM_LOOP ) );
25 34
26   - PxSpriteSheet.fetch( "pickups" ).addAnimation( new PxAnimation( "good", [ 0, 0, 0, 0, 0, 1 ], 5, PxAnimation.ANIM_LOOP ) );
27   - PxSpriteSheet.fetch( "pickups" ).addAnimation( new PxAnimation( "bad", [ 2, 2, 2, 2, 2, 2, 3 ], 5, PxAnimation.ANIM_LOOP ) );
  35 + PxRepository.fetch( "pickups" ).addAnimation( new PxAnimation( "good", [ 0, 0, 0, 0, 0, 1 ], 5, PxAnimation.ANIM_LOOP ) );
  36 + PxRepository.fetch( "pickups" ).addAnimation( new PxAnimation( "bad", [ 2, 2, 2, 2, 2, 2, 3 ], 5, PxAnimation.ANIM_LOOP ) );
28 37 }
29 38
30 39 // background color of scene
45 examples/platformer/Player.as
... ... @@ -1,6 +1,5 @@
1 1 package examples.platformer {
2 2
3   - import examples.assets.AssetFactory;
4 3 import pixelizer.components.collision.PxBoxColliderComponent;
5 4 import pixelizer.components.collision.PxGridColliderComponent;
6 5 import pixelizer.components.PxBodyComponent;
@@ -14,6 +13,7 @@ package examples.platformer {
14 13 import pixelizer.render.PxBlitRenderer;
15 14 import pixelizer.render.PxSpriteSheet;
16 15 import pixelizer.sound.PxSoundEntity;
  16 + import pixelizer.utils.PxRepository;
17 17
18 18 /**
19 19 * ...
@@ -21,6 +21,9 @@ package examples.platformer {
21 21 */
22 22 public class Player extends PxActorEntity {
23 23
  24 + [Embed( source="../assets/jump.mp3" )]
  25 + private static var jumpSoundCls : Class;
  26 +
24 27 private var _onGround : Boolean = false;
25 28
26 29 private var _alive : Boolean = true;
@@ -29,15 +32,32 @@ package examples.platformer {
29 32 super();
30 33
31 34 // animComponent, to handle sprite sheet animations
32   - animComp.spriteSheet = PxSpriteSheet.fetch( "player" );
  35 + animComp.spriteSheet = PxRepository.fetch( "player" );
33 36 animComp.gotoAndPlay( "idle" );
34 37
35   - // set up collider size
  38 + // set up collider
36 39 boxColliderComp.setSize( 16, 16 );
37 40 boxColliderComp.registerCallbacks( onCollisionStart, onCollisionOngoing, onCollisionEnd );
  41 +
  42 + reset();
  43 + }
38 44
  45 +
  46 + // reset the player character
  47 + public function reset() : void {
  48 + transform.position.x = 120;
  49 + transform.position.y = 32;
  50 + _alive = true;
  51 + _onGround = false;
  52 + bodyComp.velocity.x = bodyComp.velocity.y = 0;
  53 + animComp.gotoAndPlay( "idle" );
  54 +
  55 + // what to collide with
  56 + boxColliderComp.enableCollisionWithCollisionLayer( 1 ); // pick ups
  57 + boxColliderComp.enableCollisionWithCollisionLayer( Pixelizer.COLLISION_LAYER_GRID ); // grid
39 58 }
40 59
  60 +
41 61 override public function dispose() : void {
42 62 super.dispose();
43 63 }
@@ -65,7 +85,7 @@ package examples.platformer {
65 85 if ( PxInput.isDown( PxInput.KEY_UP ) ) {
66 86 bodyComp.velocity.y -= 11;
67 87 animComp.gotoAndPlay( "jump" );
68   - addEntity( new PxSoundEntity( AssetFactory.jumpSound, Pixelizer.ZERO_POINT ) );
  88 + addEntity( new PxSoundEntity( new jumpSoundCls(), Pixelizer.ZERO_POINT ) );
69 89 }
70 90 }
71 91
@@ -96,11 +116,8 @@ package examples.platformer {
96 116 animComp.gotoAndPlay( "idle" );
97 117 }
98 118 }
  119 +
99 120 // collided with heart?
100   - else if ( pCollisionData.otherCollider.entity is GoodPickup ) {
101   - pCollisionData.otherCollider.entity.destroyIn( 0 );
102   - }
103   - // collided with skull?
104 121 else if ( pCollisionData.otherCollider.entity is BadPickup ) {
105 122 die();
106 123 }
@@ -129,18 +146,6 @@ package examples.platformer {
129 146 }
130 147 }
131 148
132   - // reset the player character
133   - public function reset() : void {
134   - transform.position.x = 120;
135   - transform.position.y = 32;
136   - _alive = true;
137   - _onGround = false;
138   - bodyComp.velocity.x = bodyComp.velocity.y = 0;
139   - animComp.gotoAndPlay( "idle" );
140   -
141   - boxColliderComp.collisionLayerMask = 1 + 2;
142   - boxColliderComp.collisionLayer = 2;
143   - }
144 149
145 150 }
146 151
5 examples/platformer/TileMap.as
@@ -3,6 +3,7 @@ package examples.platformer {
3 3 import pixelizer.components.render.PxTileMapComponent;
4 4 import pixelizer.PxEntity;
5 5 import pixelizer.render.PxSpriteSheet;
  6 + import pixelizer.utils.PxRepository;
6 7
7 8 /**
8 9 * Shows tiled graphics and holds the collision for the tilemap
@@ -20,13 +21,13 @@ package examples.platformer {
20 21 _height = pLevelXML.@height;
21 22
22 23 // add collision
23   - _gridComponent = new PxGridColliderComponent( _width, _height );
  24 + _gridComponent = new PxGridColliderComponent( _width, _height, 16 );
24 25 _gridComponent.grid.populateFromBitString( pLevelXML[ "solid" ][ 0 ], 1 );
25 26 _gridComponent.grid.populateFromBitString( pLevelXML[ "jump_through" ][ 0 ], 2, false );
26 27 addComponent( _gridComponent );
27 28
28 29 // add tiled graphics
29   - var tileMapComp : PxTileMapComponent = new PxTileMapComponent( _width, _height, PxSpriteSheet.fetch( "tiles" ) );
  30 + var tileMapComp : PxTileMapComponent = new PxTileMapComponent( _width, _height, PxRepository.fetch( "tiles" ) );
30 31 tileMapComp.populateFromXML( pLevelXML[ "background" ][ 0 ] );
31 32 addComponent( tileMapComp );
32 33 }
71 examples/replay/ReplayEntity.as
... ... @@ -0,0 +1,71 @@
  1 +package examples.replay {
  2 + import pixelizer.components.render.PxBlitRenderComponent;
  3 + import pixelizer.Pixelizer;
  4 + import pixelizer.PxEntity;
  5 + import pixelizer.PxInput;
  6 + import pixelizer.utils.PxImageUtil;
  7 + import pixelizer.utils.PxInputPost;
  8 + import pixelizer.utils.PxInputSequence;
  9 +
  10 + /**
  11 + * ...
  12 + * @author Johan Peitz
  13 + */
  14 + public class ReplayEntity extends PxEntity {
  15 +
  16 + private var _recordInput : Boolean = false;
  17 + private var _inputSequence : PxInputSequence;
  18 +
  19 + public function ReplayEntity() {
  20 + addComponent( new PxBlitRenderComponent( PxImageUtil.createRect( 16, 16 ) ) );
  21 +
  22 + transform.setPosition( 160, 120 );
  23 +
  24 + _recordInput = true;
  25 + _inputSequence = new PxInputSequence();
  26 + }
  27 +
  28 + override public function update( pDT : Number ) : void {
  29 + var input : PxInputPost = new PxInputPost();
  30 +
  31 + if ( _recordInput ) {
  32 + input = new PxInputPost();
  33 + input.left = PxInput.isDown( PxInput.KEY_LEFT );
  34 + input.right = PxInput.isDown( PxInput.KEY_RIGHT );
  35 + input.up = PxInput.isDown( PxInput.KEY_UP );
  36 + input.down = PxInput.isDown( PxInput.KEY_DOWN );
  37 + _inputSequence.storePost( input );
  38 + } else {
  39 + input = _inputSequence.fetchPost();
  40 + if ( input == null ) {
  41 + input = new PxInputPost()
  42 + replay();
  43 + }
  44 + }
  45 +
  46 + var speed : Number = 60;
  47 + if ( input.up ) {
  48 + transform.position.y -= speed * pDT;
  49 + }
  50 + if ( input.down ) {
  51 + transform.position.y += speed * pDT;
  52 + }
  53 + if ( input.left ) {
  54 + transform.position.x -= speed * pDT;
  55 + }
  56 + if ( input.right ) {
  57 + transform.position.x += speed * pDT;
  58 + }
  59 +
  60 + super.update( pDT );
  61 + }
  62 +
  63 + public function replay() : void {
  64 + _recordInput = false;
  65 + transform.setPosition( 160, 120 );
  66 + _inputSequence.restart();
  67 + }
  68 +
  69 + }
  70 +
  71 +}
49 examples/replay/ReplayExampleScene.as
... ... @@ -0,0 +1,49 @@
  1 +package examples.replay {
  2 + import pixelizer.Pixelizer;
  3 + import pixelizer.prefabs.gui.PxTextFieldEntity;
  4 + import pixelizer.PxInput;
  5 + import pixelizer.PxScene;
  6 +
  7 + /**
  8 + * ...
  9 + * @author Johan Peitz
  10 + */
  11 + public class ReplayExampleScene extends PxScene {
  12 +
  13 + private var _currentEntity : ReplayEntity;
  14 +
  15 + public function ReplayExampleScene() {
  16 + var text : PxTextFieldEntity = new PxTextFieldEntity( "Arrows to move box. SPACE to create new box." );
  17 + text.textField.alignment = Pixelizer.CENTER;
  18 + text.textField.width = 320;
  19 + text.transform.position.y = 10;
  20 + addEntity( text );
  21 +
  22 + spawnEntity();
  23 + }
  24 +
  25 + private function spawnEntity() : void {
  26 + if ( _currentEntity != null ) {
  27 + _currentEntity.replay();
  28 + }
  29 + _currentEntity = new ReplayEntity( );
  30 + addEntity( _currentEntity );
  31 + }
  32 +
  33 + override public function update( pDT : Number ) : void {
  34 + if ( PxInput.isPressed( PxInput.KEY_SPACE ) ) {
  35 + spawnEntity();
  36 + }
  37 +
  38 + if ( PxInput.isPressed( PxInput.KEY_ESC ) ) {
  39 + engine.popScene();
  40 + }
  41 +
  42 +
  43 + super.update( pDT );
  44 + }
  45 +
  46 +
  47 + }
  48 +
  49 +}
5 examples/sound/SoundExampleScene.as
... ... @@ -1,5 +1,4 @@
1 1 package examples.sound {
2   - import examples.assets.AssetFactory;
3 2 import flash.geom.Point;
4 3 import pixelizer.components.render.PxBlitRenderComponent;
5 4 import pixelizer.components.render.PxTextFieldComponent;
@@ -12,6 +11,8 @@ package examples.sound {
12 11 import pixelizer.utils.PxImageUtil;
13 12
14 13 public class SoundExampleScene extends PxScene {
  14 + [Embed( source="../assets/sheep.mp3" )]
  15 + private static var sheepSoundCls : Class;
15 16
16 17 public function SoundExampleScene() {
17 18
@@ -54,7 +55,7 @@ package examples.sound {
54 55
55 56 override public function update( pDT : Number ) : void {
56 57 if ( PxInput.mousePressed ) {
57   - addEntity( new VisibleSoundEntity( AssetFactory.sheepSound, PxInput.mousePosition ) );
  58 + addEntity( new VisibleSoundEntity( new sheepSoundCls(), PxInput.mousePosition ) );
58 59 // could also have been
59 60 // PxSoundManager.play( new _sheepSound(), PxInput.mousePosition );
60 61 // but then we wouldn't see it
6 examples/sound/SoundMaker.as
... ... @@ -1,5 +1,4 @@
1 1 package examples.sound {
2   - import examples.assets.AssetFactory;
3 2 import pixelizer.components.render.PxBlitRenderComponent;
4 3 import pixelizer.Pixelizer;
5 4 import pixelizer.PxEntity;
@@ -11,13 +10,16 @@ package examples.sound {
11 10 */
12 11 public class SoundMaker extends PxEntity {
13 12
  13 + [Embed( source="../assets/bird_song.mp3" )]
  14 + private static var birdSoundCls : Class;
  15 +
14 16 private var _timePassed : Number = 0;
15 17
16 18 public function SoundMaker() {
17 19 super( 160, 120 );
18 20 addComponent( new PxBlitRenderComponent( PxImageUtil.createRect( 32, 32, Pixelizer.COLOR_BLUE ) ) );
19 21
20   - addEntity( new VisibleSoundEntity( AssetFactory.birdSound, Pixelizer.ZERO_POINT, true ) );
  22 + addEntity( new VisibleSoundEntity( new birdSoundCls(), Pixelizer.ZERO_POINT, true ) );
21 23 }
22 24
23 25 override public function update( pDT : Number ) : void {
16 examples/spritesheet/SpriteSheetExampleScene.as
... ... @@ -1,5 +1,4 @@
1 1 package examples.spritesheet {
2   - import examples.assets.AssetFactory;
3 2 import flash.display.MovieClip;
4 3 import flash.display.StageQuality;
5 4 import pixelizer.components.render.PxAnimationComponent;
@@ -20,6 +19,12 @@ package examples.spritesheet {
20 19 */
21 20 public class SpriteSheetExampleScene extends PxScene {
22 21
  22 + [Embed( source="../assets/player.png" )]
  23 + private static var playerBitmapCls : Class;
  24 +
  25 + [Embed( source="../assets/animation.swf",symbol="animation" )]
  26 + private static var mcAnimationCls : Class;
  27 +
23 28 private var _animComp : PxAnimationComponent;
24 29 private var _timePassed : Number = 0;
25 30 private var _animID : int = 0;
@@ -28,7 +33,7 @@ package examples.spritesheet {
28 33 var i : int;
29 34
30 35 var sheet : PxSpriteSheet = new PxSpriteSheet();
31   - var numFrames : int = sheet.addFramesFromMovieClip( AssetFactory.mc, StageQuality.HIGH );
  36 + var numFrames : int = sheet.addFramesFromMovieClip( new mcAnimationCls(), StageQuality.HIGH );
32 37 var frames : Array = [];
33 38 for ( i = 0; i < numFrames; i++ ) {
34 39 frames.push( i );
@@ -42,7 +47,7 @@ package examples.spritesheet {
42 47 addEntity( e );
43 48
44 49 sheet = new PxSpriteSheet();
45   - numFrames = sheet.addFramesFromMovieClip( AssetFactory.mc, StageQuality.LOW );
  50 + numFrames = sheet.addFramesFromMovieClip( new mcAnimationCls(), StageQuality.LOW );
46 51 frames = [];
47 52 for ( i = 0; i < numFrames; i++ ) {
48 53 frames.push( i );
@@ -56,7 +61,7 @@ package examples.spritesheet {
56 61 addEntity( e );
57 62
58 63 sheet = new PxSpriteSheet();
59   - sheet.addFramesFromBitmapData( AssetFactory.player, 16, 16 );
  64 + sheet.addFramesFromBitmapData( new playerBitmapCls().bitmapData, 16, 16 );
60 65 sheet.addAnimation( new PxAnimation( "idle", [ 0 ] ) );
61 66 sheet.addAnimation( new PxAnimation( "run", [ 0, 1 ], 10, PxAnimation.ANIM_LOOP ) );
62 67 sheet.addAnimation( new PxAnimation( "jump", [ 2 ] ) );
@@ -67,7 +72,8 @@ package examples.spritesheet {
67 72 _animComp.gotoAndPlay( "run" );
68 73 e.addComponent( _animComp );
69 74 addEntity( e );
70   -
  75 +
  76 +
71 77 addEntity( new PxTextFieldEntity( "Frames from SWF (high quality). Frames from SWF (low quality)." ) ).transform.setPosition( 20, 20 );
72 78 addEntity( new PxTextFieldEntity( "Frames from image." ) ).transform.setPosition( 20, 120 );
73 79 }
13 examples/text/TextExampleScene.as
... ... @@ -1,5 +1,5 @@
1 1 package examples.text {
2   - import examples.assets.AssetFactory;
  2 + import pixelizer.components.PxTransformComponent;
3 3 import pixelizer.components.render.PxTextFieldComponent;
4 4 import pixelizer.Pixelizer;
5 5 import pixelizer.prefabs.gui.PxTextFieldEntity;
@@ -10,8 +10,13 @@ package examples.text {
10 10
11 11 public class TextExampleScene extends PxScene {
12 12
  13 + [Embed( source="../assets/round_font.png" )]
  14 + private static var roundFontCls : Class;
  15 +
13 16 private var _fieldCount : int = 0;
14 17
  18 +
  19 +
15 20 public function TextExampleScene() {
16 21 // bg color of scene
17 22 backgroundColor = Pixelizer.COLOR_WHITE;
@@ -36,7 +41,7 @@ package examples.text {
36 41 addTextEntity( textEntity );
37 42
38 43 // shadowed text
39   - textEntity = new PxTextFieldEntity( "and have a dramatic shadow.", Pixelizer.COLOR_GRAY );
  44 + textEntity = new PxTextFieldEntity( "and have a dramatic shadow.", Pixelizer.COLOR_LIGHT_GRAY );
40 45 textEntity.textField.shadow = true;
41 46 textEntity.textField.shadowColor = Pixelizer.COLOR_BLUE;
42 47 addTextEntity( textEntity );
@@ -73,8 +78,10 @@ package examples.text {
73 78 addTextEntity( textEntity );
74 79
75 80 // text with other font
  81 + var letters : String = " !\"#$%&'()*+,-./" + "0123456789:;<=>?" + "@ABCDEFGHIJKLMNO" + "PQRSTUVWXYZ[}]^_" + "'abcdefghijklmno" + "pqrstuvwxyz{|}~\\";
  82 + var font : PxBitmapFont = new PxBitmapFont( new roundFontCls().bitmapData, letters );
76 83 textEntity = new PxTextFieldEntity( "OH! A different font! Very fancy.", Pixelizer.COLOR_BLUE );
77   - textEntity.textField.font = AssetFactory.roundFont;
  84 + textEntity.textField.font = font;
78 85 textEntity.textField.shadow = true;
79 86 textEntity.textField.shadowColor = Pixelizer.COLOR_RED;
80 87 addTextEntity( textEntity );
6 examples/transform/TransformExampleScene.as
... ... @@ -1,5 +1,4 @@
1 1 package examples.transform {
2   - import examples.assets.AssetFactory;
3 2 import flash.display.Bitmap;
4 3 import flash.display.BitmapData;
5 4 import flash.geom.Point;
@@ -13,6 +12,9 @@ package examples.transform {
13 12 import pixelizer.utils.PxMath;
14 13
15 14 public class TransformExampleScene extends PxScene {
  15 + [Embed( source="../assets/box.png" )]
  16 + private static var boxCls : Class;
  17 +
16 18 private var _yScaleEntity : PxEntity;
17 19 private var _xScaleEntity : PxEntity;
18 20 private var _rotatingEntity : PxEntity;
@@ -36,7 +38,7 @@ package examples.transform {
36 38 addEntity( textEntity );
37 39
38 40 // image to use
39   - var bd : BitmapData = AssetFactory.box;
  41 + var bd : BitmapData = new boxCls().bitmapData;
40 42
41 43 // position examples
42 44 _stillEntity = new PxEntity( 40, 80 );
15 pixelizer/Pixelizer.as
@@ -15,23 +15,28 @@ package pixelizer {
15 15 */
16 16 public class Pixelizer {
17 17 public static const MAJOR_VERSION : int = 0;
18   - public static const MINOR_VERSION : int = 3;
19   - public static const INTERNAL_VERSION : int = 0;
20   -
  18 + public static const MINOR_VERSION : int = 4;
  19 + public static const INTERNAL_VERSION : int = 3;
  20 +
21 21 public static const COLOR_RED : int = 0xFF5D5D;
22 22 public static const COLOR_GREEN : int = 0x5DFC5D;
23 23 public static const COLOR_BLUE : int = 0x5CBCFC;
24 24 public static const COLOR_WHITE : int = 0xFFFFFF;
25   - public static const COLOR_BLACK : int = 0x000000;
26   - public static const COLOR_GRAY : int = 0xE6E6E6;
  25 + public static const COLOR_BLACK : int = 0x000000;
  26 + public static const COLOR_LIGHT_GRAY : int = 0xE6E6E6;
  27 + public static const COLOR_GRAY : int = 0xAAAAAA;
  28 + public static const COLOR_DARK_GRAY : int = 0x808080;
27 29
28 30 public static const LEFT : int = 1;
29 31 public static const RIGHT : int = 2;
30 32 public static const CENTER : int = 3;
31 33
  34 + static public const NO_FLIP : int = 0;
32 35 static public const H_FLIP : int = 1;
33 36 static public const V_FLIP : int = 2;
34 37
  38 + static public const COLLISION_LAYER_GRID : int = 0;
  39 +
35 40 /**
36 41 * Object pool for points.
37 42 * Fetch and recycle Points here for added performance.
6 pixelizer/PxEngine.as
@@ -209,7 +209,7 @@ package pixelizer {
209 209
210 210 _noFocusEntity = new PxEntity();
211 211 _noFocusEntity.transform.scale = 2;
212   - var blocker : PxBlitRenderComponent = new PxBlitRenderComponent( PxImageUtil.createRect( _width / 2, _height / 2, Pixelizer.COLOR_GRAY ), new Point() );
  212 + var blocker : PxBlitRenderComponent = new PxBlitRenderComponent( PxImageUtil.createRect( _width / 2, _height / 2, Pixelizer.COLOR_LIGHT_GRAY ), new Point() );
213 213 blocker.alpha = 0.5;
214 214 _noFocusEntity.addComponent( blocker );
215 215 var message : PxTextFieldComponent = new PxTextFieldComponent();
@@ -394,14 +394,14 @@ package pixelizer {
394 394 PxLog.log( "turning performance view ON", "[o Pixelizer]", PxLog.DEBUG );
395 395 _performaceView = new PxTextFieldEntity( "", Pixelizer.COLOR_BLACK );
396 396 _performaceView.textField.background = true;
397   - _performaceView.textField.backgroundColor = Pixelizer.COLOR_GRAY;
  397 + _performaceView.textField.backgroundColor = Pixelizer.COLOR_LIGHT_GRAY;
398 398 _performaceView.textField.padding = 2;
399 399 _performaceView.textField.alpha = 0.8;
400 400 _internalScene.entityRoot.addEntity( _performaceView );
401 401
402 402 _logView = new PxTextFieldEntity( "", Pixelizer.COLOR_BLACK );
403 403 _logView.textField.background = true;
404   - _logView.textField.backgroundColor = Pixelizer.COLOR_GRAY;
  404 + _logView.textField.backgroundColor = Pixelizer.COLOR_LIGHT_GRAY;
405 405 _logView.textField.padding = 2;
406 406 _logView.textField.alpha = 0.8;
407 407 _logView.textField.width = _width;
3  pixelizer/components/collision/PxBoxColliderComponent.as
@@ -19,9 +19,6 @@ package pixelizer.components.collision {
19 19 public function PxBoxColliderComponent( pWidth : Number, pHeight : Number, pSolid : Boolean = true ) {
20 20 super( pSolid );
21 21 collisionBox = new PxAABB( pWidth, pHeight, pWidth / 2, pHeight / 2 );
22   - addCollisionLayer( 1 ); // i'm a box
23   - addCollisionLayerMask( 0 ); // grids
24   - addCollisionLayerMask( 1 ); // other boxes
25 22 }
26 23
27 24 /**
3  pixelizer/components/collision/PxBoxColliderRenderComponent.as