Permalink
Browse files

ADDED Possibility to get regpoints

  • Loading branch information...
1 parent 5d09839 commit c80546d308cae1a6c573815f4112dee14e3e02e9 @potmo committed Apr 16, 2012
View
6 src/com/potmo/p2d/atlas/P2DTextureAtlas.as
@@ -320,6 +320,12 @@ package com.potmo.p2d.atlas
}
+ public function getRegpoints():Vector.<Point>
+ {
+ return _regpoints.concat(); //clone
+ }
+
+
public function getVertexBuffer():VertexBuffer3D
{
return _vertexBuffer;
View
9 src/com/potmo/p2d/atlas/animation/P2DSpriteAtlas.as
@@ -9,13 +9,13 @@ package com.potmo.p2d.atlas.animation
private var _sequenceCount:uint;
- public function P2DSpriteAtlas( sequenceFrames:Vector.<int>, names:Vector.<String>, labels:Vector.<String>, frameSizes:Vector.<Point> )
+ public function P2DSpriteAtlas( sequenceFrames:Vector.<int>, names:Vector.<String>, labels:Vector.<String>, frameSizes:Vector.<Point>, regPoints:Vector.<Point> )
{
_sequences = new Vector.<P2DSpriteAtlasSequence>();
_sequenceCount = 0;
- createSequences( sequenceFrames, names, labels, frameSizes );
+ createSequences( sequenceFrames, names, labels, frameSizes, regPoints );
}
@@ -54,7 +54,7 @@ package com.potmo.p2d.atlas.animation
}
- private function createSequences( sequenceFrames:Vector.<int>, names:Vector.<String>, labels:Vector.<String>, frameSizes:Vector.<Point> ):void
+ private function createSequences( sequenceFrames:Vector.<int>, names:Vector.<String>, labels:Vector.<String>, frameSizes:Vector.<Point>, regpoints:Vector.<Point> ):void
{
var length:int = names.length;
@@ -64,6 +64,7 @@ package com.potmo.p2d.atlas.animation
var sequenceName:String = names[ i ];
var sequenceFrame:int = sequenceFrames[ i ]
var label:String = labels[ i ];
+ var regpoint:Point = regpoints[ i ];
var sequence:P2DSpriteAtlasSequence = getP2DSequenceByName( sequenceName );
@@ -73,7 +74,7 @@ package com.potmo.p2d.atlas.animation
}
var frameSize:Point = frameSizes[ i ];
- sequence.addFrame( sequenceFrame, i, label, frameSize );
+ sequence.addFrame( sequenceFrame, i, label, frameSize, regpoint );
}
}
View
22 src/com/potmo/p2d/atlas/animation/P2DSpriteAtlasSequence.as
@@ -16,15 +16,17 @@ package com.potmo.p2d.atlas.animation
private var _labels:Vector.<String>;
private var _atlasFrames:Vector.<uint>;
private var _sequenceOffsetInAtlas:uint;
- private var _frameSize:Vector.<Point>;
+ private var _frameSizes:Vector.<Point>;
+ private var _regPoints:Vector.<Point>;
public function P2DSpriteAtlasSequence( name:String )
{
_name = name;
_labels = new Vector.<String>();
_atlasFrames = new Vector.<uint>();
- _frameSize = new Vector.<Point>();
+ _frameSizes = new Vector.<Point>();
+ _regPoints = new Vector.<Point>();
_sequenceFrameCount = 0;
}
@@ -91,18 +93,21 @@ package com.potmo.p2d.atlas.animation
}
- public function addFrame( sequenceFrame:int, atlasFrame:uint, label:String, frameSize:Point ):void
+ public function addFrame( sequenceFrame:int, atlasFrame:uint, label:String, frameSize:Point, regPoint:Point ):void
{
while ( sequenceFrame >= _sequenceFrameCount )
{
_labels.push( null );
_atlasFrames.push( -1 );
+ _frameSizes.push( null );
+ _regPoints.push( null );
_sequenceFrameCount++;
}
_labels[ sequenceFrame ] = label;
_atlasFrames[ sequenceFrame ] = atlasFrame;
- _frameSize[ sequenceFrame ] = frameSize;
+ _frameSizes[ sequenceFrame ] = frameSize;
+ _regPoints[ sequenceFrame ] = regPoint;
}
@@ -164,7 +169,14 @@ package com.potmo.p2d.atlas.animation
public function getSizeOfFrame( atlasFrame:uint ):Point
{
var sequenceFrame:int = getSequenceFrameFromAtlasFrame( atlasFrame );
- return _frameSize[ sequenceFrame ];
+ return _frameSizes[ sequenceFrame ];
+ }
+
+
+ public function getRegpointOfFrame( atlasFrame:uint ):Point
+ {
+ var sequenceFrame:int = getSequenceFrameFromAtlasFrame( atlasFrame );
+ return _regPoints[ sequenceFrame ];
}
}
View
1 src/com/potmo/p2d/atlas/animation/SpriteAtlasSequence.as
@@ -10,5 +10,6 @@ package com.potmo.p2d.atlas.animation
function getName():String;
function getNextFrame( currentFrame:uint, loop:Boolean, followLabelPointers:Boolean ):uint;
function getSizeOfFrame( atlasFrame:uint ):Point;
+ function getRegpointOfFrame( atlasFrame:uint ):Point;
}
}
View
2 src/com/potmo/p2d/renderer/P2DRenderer.as
@@ -124,7 +124,7 @@ package com.potmo.p2d.renderer
_transformVector[ 0 ] = redMultiplyer;
_transformVector[ 1 ] = greenMultiplyer;
_transformVector[ 2 ] = blueMultiplyer;
- _transformVector[ 3 ] = greenMultiplyer;
+ _transformVector[ 3 ] = alphaMultiplyer;
_context.setProgramConstantsFromVector( Context3DProgramType.VERTEX, 0, _transformVector, 1 ); // this is the colortransform but we dont care about it now
_context.setProgramConstantsFromVector( Context3DProgramType.VERTEX, 1, _matrixVector, 3 );

0 comments on commit c80546d

Please sign in to comment.