<!DOCTYPE html>

<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Phaser Source: animation/Frame.js</title>

	<!--[if lt IE 9]>
	<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
	<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">

	
	<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
	
</head>

<body>
<div class="container-fluid">
	<div class="navbar navbar-fixed-top navbar-inverse">
		<div class="navbar-inner">
			<a class="brand" href="index.html">Phaser</a>
			<ul class="nav">
				
				<li class="dropdown">
					<a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b
						class="caret"></b></a>

					<ul class="dropdown-menu ">
						
						<li>
							<a href="module-Phaser.html">Phaser</a>
						</li>
						

					</ul>
				</li>
				
				<li class="dropdown">
					<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
						class="caret"></b></a>

					<ul class="dropdown-menu ">
						
						<li>
							<a href="Phaser.Animation.html">Animation</a>
						</li>
						
						<li>
							<a href="Phaser.Animation.Frame.html">Frame</a>
						</li>
						
						<li>
							<a href="Phaser.Animation.FrameData.html">FrameData</a>
						</li>
						
						<li>
							<a href="Phaser.Animation.Parser.html">Parser</a>
						</li>
						
						<li>
							<a href="Phaser.AnimationManager.html">AnimationManager</a>
						</li>
						
						<li>
							<a href="Phaser.Camera.html">Camera</a>
						</li>
						
						<li>
							<a href="Phaser.Game.html">Game</a>
						</li>
						
						<li>
							<a href="Phaser.Group.html">Group</a>
						</li>
						

					</ul>
				</li>
				
			</ul>
		</div>
	</div>

	<div class="row-fluid">

		
			<div class="span12">
				
				<div id="main">
					


		<h1 class="page-title">Source: animation/Frame.js</h1>
    
    <section>
        <article>
            <pre class="sunlight-highlight-javascript linenums">/**
* @author       Richard Davey &lt;rich@photonstorm.com>
* @copyright    2013 Photon Storm Ltd.
* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/

/**
* A Frame is a single frame of an animation and is part of a FrameData collection.
*
* @class Phaser.Animation.Frame
* @constructor
* @param {number} index - The index of this Frame within the FrameData set it is being added to.
* @param {number} x - X position of the frame within the texture image.
* @param {number} y - Y position of the frame within the texture image.
* @param {number} width - Width of the frame within the texture image.
* @param {number} height - Height of the frame within the texture image.
* @param {string} name - The name of the frame. In Texture Atlas data this is usually set to the filename.
* @param {string} uuid - Internal UUID key.
*/
Phaser.Animation.Frame = function (index, x, y, width, height, name, uuid) {

	/**
	* @property {number} index - The index of this Frame within the FrameData set it is being added to.
	*/
	this.index = index;
	
	/**
	* @property {number} x - X position within the image to cut from.
	*/
	this.x = x;

	/**
	* @property {number} y - Y position within the image to cut from.
	*/
	this.y = y;

	/**
	* @property {number} width - Width of the frame.
	*/
	this.width = width;

	/**
	* @property {number} height - Height of the frame.
	*/
	this.height = height;

	/**
	* @property {string} name - Useful for Texture Atlas files (is set to the filename value).
	*/
	this.name = name;

	/**
	* @property {string} uuid - A link to the PIXI.TextureCache entry.
	*/
	this.uuid = uuid;

	/**
	* @property {number} centerX - Center X position within the image to cut from.
	*/
    this.centerX = Math.floor(width / 2);

	/**
	* @property {number} centerY - Center Y position within the image to cut from.
	*/
    this.centerY = Math.floor(height / 2);

	/**
	* @property {number} distance - The distance from the top left to the bottom-right of this Frame.
	*/
	this.distance = Phaser.Math.distance(0, 0, width, height);

	/**
	* @property {boolean} rotated - Rotated? (not yet implemented)
	* @default
	*/
	this.rotated = false;

	/**
	* @property {string} rotationDirection - Either 'cw' or 'ccw', rotation is always 90 degrees.
	* @default 'cw'
	*/
	this.rotationDirection = 'cw';

	/**
	* @property {boolean} trimmed - Was it trimmed when packed?
	* @default
	*/
	this.trimmed = false;

	/**
	* @property {number} sourceSizeW - Width of the original sprite.
	*/
    this.sourceSizeW = width;

	/**
	* @property {number} sourceSizeH - Height of the original sprite.
	*/
    this.sourceSizeH = height;

	/**
	* @property {number} spriteSourceSizeX - X position of the trimmed sprite inside original sprite.
	* @default
	*/
	this.spriteSourceSizeX = 0;

	/**
	* @property {number} spriteSourceSizeY - Y position of the trimmed sprite inside original sprite.
	* @default
	*/
	this.spriteSourceSizeY = 0;

	/**
	* @property {number} spriteSourceSizeW - Width of the trimmed sprite.
	* @default
	*/
	this.spriteSourceSizeW = 0;

	/**
	* @property {number} spriteSourceSizeH - Height of the trimmed sprite.
	* @default
	*/
	this.spriteSourceSizeH = 0;

};

Phaser.Animation.Frame.prototype = {

	/**
	* If the frame was trimmed when added to the Texture Atlas this records the trim and source data.
	*
	* @method Phaser.Animation.Frame#setTrim
	* @param {boolean} trimmed - If this frame was trimmed or not.
	* @param {number} actualWidth - The width of the frame before being trimmed.
	* @param {number} actualHeight - The height of the frame before being trimmed.
	* @param {number} destX - The destination X position of the trimmed frame for display.
	* @param {number} destY - The destination Y position of the trimmed frame for display.
	* @param {number} destWidth - The destination width of the trimmed frame for display.
	* @param {number} destHeight - The destination height of the trimmed frame for display.
	*/
    setTrim: function (trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) {

        this.trimmed = trimmed;

        if (trimmed)
        {
            this.width = actualWidth;
            this.height = actualHeight;
            this.sourceSizeW = actualWidth;
            this.sourceSizeH = actualHeight;
		    this.centerX = Math.floor(actualWidth / 2);
		    this.centerY = Math.floor(actualHeight / 2);
            this.spriteSourceSizeX = destX;
            this.spriteSourceSizeY = destY;
            this.spriteSourceSizeW = destWidth;
            this.spriteSourceSizeH = destHeight;
        }

    }

};
</pre>
        </article>
    </section>





				</div>

				<div class="clearfix"></div>
				<footer>
					
					
		<span class="copyright">
		Phaser Copyright © 2012-2013 Photon Storm Ltd.
		</span>
					<br />
					
		<span class="jsdoc-message">
		Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0-dev</a>
		on Wed Oct 02 2013 01:12:17 GMT+0100 (BST) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
		</span>
				</footer>
			</div>

			
			<br clear="both">
		</div>

	</div>
	<script src="scripts/sunlight.js"></script>
	<script src="scripts/sunlight.javascript.js"></script>
	<script src="scripts/sunlight-plugin.doclinks.js"></script>
	<script src="scripts/sunlight-plugin.linenumbers.js"></script>
	<script src="scripts/sunlight-plugin.menu.js"></script>
	<script src="scripts/jquery.min.js"></script>
	<script src="scripts/jquery.scrollTo.js"></script>
	<script src="scripts/jquery.localScroll.js"></script>
	<script src="scripts/bootstrap-dropdown.js"></script>
	<script src="scripts/toc.js"></script>


	<script>  Sunlight.highlightAll({lineNumbers:true,  showMenu: true, enableDoclinks :true}); </script>

	<script>
		$( function () {
			$( "#toc" ).toc( {
				selectors   : "h1,h2,h3,h4",
				showAndHide : false,
				scrollTo    : 60
			} );
			$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
			$( "#main span[id^='toc']" ).addClass( "toc-shim" );

		} );
	</script>

	

</body>
</html>