Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

ADDED Possibility to get regpoints

  • Loading branch information...
commit c80546d308cae1a6c573815f4112dee14e3e02e9 1 parent 5d09839
Nisse Bergman authored April 16, 2012
6  src/com/potmo/p2d/atlas/P2DTextureAtlas.as
@@ -320,6 +320,12 @@ package com.potmo.p2d.atlas
320 320
 		}
321 321
 
322 322
 
  323
+		public function getRegpoints():Vector.<Point>
  324
+		{
  325
+			return _regpoints.concat(); //clone
  326
+		}
  327
+
  328
+
323 329
 		public function getVertexBuffer():VertexBuffer3D
324 330
 		{
325 331
 			return _vertexBuffer;
9  src/com/potmo/p2d/atlas/animation/P2DSpriteAtlas.as
@@ -9,13 +9,13 @@ package com.potmo.p2d.atlas.animation
9 9
 		private var _sequenceCount:uint;
10 10
 
11 11
 
12  
-		public function P2DSpriteAtlas( sequenceFrames:Vector.<int>, names:Vector.<String>, labels:Vector.<String>, frameSizes:Vector.<Point> )
  12
+		public function P2DSpriteAtlas( sequenceFrames:Vector.<int>, names:Vector.<String>, labels:Vector.<String>, frameSizes:Vector.<Point>, regPoints:Vector.<Point> )
13 13
 		{
14 14
 
15 15
 			_sequences = new Vector.<P2DSpriteAtlasSequence>();
16 16
 			_sequenceCount = 0;
17 17
 
18  
-			createSequences( sequenceFrames, names, labels, frameSizes );
  18
+			createSequences( sequenceFrames, names, labels, frameSizes, regPoints );
19 19
 
20 20
 		}
21 21
 
@@ -54,7 +54,7 @@ package com.potmo.p2d.atlas.animation
54 54
 		}
55 55
 
56 56
 
57  
-		private function createSequences( sequenceFrames:Vector.<int>, names:Vector.<String>, labels:Vector.<String>, frameSizes:Vector.<Point> ):void
  57
+		private function createSequences( sequenceFrames:Vector.<int>, names:Vector.<String>, labels:Vector.<String>, frameSizes:Vector.<Point>, regpoints:Vector.<Point> ):void
58 58
 		{
59 59
 			var length:int = names.length;
60 60
 
@@ -64,6 +64,7 @@ package com.potmo.p2d.atlas.animation
64 64
 				var sequenceName:String = names[ i ];
65 65
 				var sequenceFrame:int = sequenceFrames[ i ]
66 66
 				var label:String = labels[ i ];
  67
+				var regpoint:Point = regpoints[ i ];
67 68
 
68 69
 				var sequence:P2DSpriteAtlasSequence = getP2DSequenceByName( sequenceName );
69 70
 
@@ -73,7 +74,7 @@ package com.potmo.p2d.atlas.animation
73 74
 				}
74 75
 				var frameSize:Point = frameSizes[ i ];
75 76
 
76  
-				sequence.addFrame( sequenceFrame, i, label, frameSize );
  77
+				sequence.addFrame( sequenceFrame, i, label, frameSize, regpoint );
77 78
 
78 79
 			}
79 80
 		}
22  src/com/potmo/p2d/atlas/animation/P2DSpriteAtlasSequence.as
@@ -16,7 +16,8 @@ package com.potmo.p2d.atlas.animation
16 16
 		private var _labels:Vector.<String>;
17 17
 		private var _atlasFrames:Vector.<uint>;
18 18
 		private var _sequenceOffsetInAtlas:uint;
19  
-		private var _frameSize:Vector.<Point>;
  19
+		private var _frameSizes:Vector.<Point>;
  20
+		private var _regPoints:Vector.<Point>;
20 21
 
21 22
 
22 23
 		public function P2DSpriteAtlasSequence( name:String )
@@ -24,7 +25,8 @@ package com.potmo.p2d.atlas.animation
24 25
 			_name = name;
25 26
 			_labels = new Vector.<String>();
26 27
 			_atlasFrames = new Vector.<uint>();
27  
-			_frameSize = new Vector.<Point>();
  28
+			_frameSizes = new Vector.<Point>();
  29
+			_regPoints = new Vector.<Point>();
28 30
 			_sequenceFrameCount = 0;
29 31
 		}
30 32
 
@@ -91,18 +93,21 @@ package com.potmo.p2d.atlas.animation
91 93
 		}
92 94
 
93 95
 
94  
-		public function addFrame( sequenceFrame:int, atlasFrame:uint, label:String, frameSize:Point ):void
  96
+		public function addFrame( sequenceFrame:int, atlasFrame:uint, label:String, frameSize:Point, regPoint:Point ):void
95 97
 		{
96 98
 			while ( sequenceFrame >= _sequenceFrameCount )
97 99
 			{
98 100
 				_labels.push( null );
99 101
 				_atlasFrames.push( -1 );
  102
+				_frameSizes.push( null );
  103
+				_regPoints.push( null );
100 104
 				_sequenceFrameCount++;
101 105
 			}
102 106
 
103 107
 			_labels[ sequenceFrame ] = label;
104 108
 			_atlasFrames[ sequenceFrame ] = atlasFrame;
105  
-			_frameSize[ sequenceFrame ] = frameSize;
  109
+			_frameSizes[ sequenceFrame ] = frameSize;
  110
+			_regPoints[ sequenceFrame ] = regPoint;
106 111
 
107 112
 		}
108 113
 
@@ -164,7 +169,14 @@ package com.potmo.p2d.atlas.animation
164 169
 		public function getSizeOfFrame( atlasFrame:uint ):Point
165 170
 		{
166 171
 			var sequenceFrame:int = getSequenceFrameFromAtlasFrame( atlasFrame );
167  
-			return _frameSize[ sequenceFrame ];
  172
+			return _frameSizes[ sequenceFrame ];
  173
+		}
  174
+
  175
+
  176
+		public function getRegpointOfFrame( atlasFrame:uint ):Point
  177
+		{
  178
+			var sequenceFrame:int = getSequenceFrameFromAtlasFrame( atlasFrame );
  179
+			return _regPoints[ sequenceFrame ];
168 180
 		}
169 181
 
170 182
 	}
1  src/com/potmo/p2d/atlas/animation/SpriteAtlasSequence.as
@@ -10,5 +10,6 @@ package com.potmo.p2d.atlas.animation
10 10
 		function getName():String;
11 11
 		function getNextFrame( currentFrame:uint, loop:Boolean, followLabelPointers:Boolean ):uint;
12 12
 		function getSizeOfFrame( atlasFrame:uint ):Point;
  13
+		function getRegpointOfFrame( atlasFrame:uint ):Point;
13 14
 	}
14 15
 }
2  src/com/potmo/p2d/renderer/P2DRenderer.as
@@ -124,7 +124,7 @@ package com.potmo.p2d.renderer
124 124
 			_transformVector[ 0 ] = redMultiplyer;
125 125
 			_transformVector[ 1 ] = greenMultiplyer;
126 126
 			_transformVector[ 2 ] = blueMultiplyer;
127  
-			_transformVector[ 3 ] = greenMultiplyer;
  127
+			_transformVector[ 3 ] = alphaMultiplyer;
128 128
 
129 129
 			_context.setProgramConstantsFromVector( Context3DProgramType.VERTEX, 0, _transformVector, 1 ); // this is the colortransform but we dont care about it now
130 130
 			_context.setProgramConstantsFromVector( Context3DProgramType.VERTEX, 1, _matrixVector, 3 );

0 notes on commit c80546d

Please sign in to comment.
Something went wrong with that request. Please try again.