Game Development Reference
In-Depth Information
}
else if(currentAnimation == "WALK_FORWARD")
{
currentFrame = walkforward.startFrame;
currentStartFrame = walkforward.startFrame;
totalFrames = walkforward.startFrame +
walkforward.numberOfFrames;
}
else if(currentAnimation == "WALK_BACK")
{
currentFrame = walkback.startFrame;
currentStartFrame = walkback.startFrame;
totalFrames = walkback.startFrame +
walkback.numberOfFrames;
}
else if(currentAnimation == "IDLE")
{
currentFrame = idle.startFrame;
currentStartFrame = idle.startFrame;
totalFrames = idle.startFrame +
idle.numberOfFrames;
}
}
function UpdateSprite()
{
var uvs : Vector2[] = new Vector2[4];
var startPixel : Vector2;
var endPixel : Vector2;
startPixel.x = singleSpriteDimensions.pixelWidth *
currentFrame;
startPixel.y = singleSpriteDimensions.pixelHeight *
currentFrame;
endPixel.x = singleSpriteDimensions.pixelWidth *
(currentFrame + 1);
endPixel.y = singleSpriteDimensions.pixelHeight *
(currentFrame + 1);
uvs[0] = new Vector2(startPixel.x/texture.width,
(texture.height - endPixel.y)/texture.height);
uvs[1] = new Vector2(startPixel.x/texture.width,
(texture.height - startPixel.y)/texture.height);
uvs[2] = new Vector2(endPixel.x/texture.width,
(texture.height - startPixel.y)/texture.height);
uvs[3] = new Vector2(endPixel.x/texture.width,
(texture.height - endPixel.y)/texture.height);
mesh.uv = uvs;
Search Nedrilad ::




Custom Search