phaser/docs/Sprite.js.html

1517 lines
44 KiB
HTML
Raw Normal View History

2013-10-25 15:54:40 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
2014-11-15 20:01:46 +00:00
<title>Phaser Source: d:/wamp/www/phaser/src/pixi/display/Sprite.js</title>
2013-10-25 15:54:40 +00:00
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
2014-11-15 20:01:46 +00:00
<link type="text/css" rel="stylesheet" href="styles/default.css">
2013-10-25 15:54:40 +00:00
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
</head>
<body>
2014-11-25 00:23:44 +00:00
2013-10-25 15:54:40 +00:00
<div class="container-fluid">
<div class="navbar navbar-fixed-top navbar-inverse">
2014-11-25 00:23:44 +00:00
<div style="position: absolute; width: 143px; height: 31px; right: 10px; top: 10px; z-index: 1050"><a href="http://phaser.io"><img src="img/phaser.png" border="0" /></a></div>
2013-10-25 15:54:40 +00:00
<div class="navbar-inner">
2014-11-25 00:23:44 +00:00
<a class="brand" href="index.html">Phaser API</a>
2013-10-25 15:54:40 +00:00
<ul class="nav">
2014-11-25 00:23:44 +00:00
2013-10-25 15:54:40 +00:00
<li class="dropdown">
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
class="caret"></b></a>
<ul class="dropdown-menu ">
2014-04-10 22:13:43 +00:00
<li class="class-depth-0">
2013-10-25 15:54:40 +00:00
<a href="Phaser.html">Phaser</a>
</li>
2014-11-15 20:01:46 +00:00
<li class="class-depth-0">
<a href="PIXI.html">PIXI</a>
</li>
2013-10-25 15:54:40 +00:00
</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 ">
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Animation.html">Animation</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.AnimationManager.html">AnimationManager</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.AnimationParser.html">AnimationParser</a>
</li>
2014-04-29 14:39:02 +00:00
<li class="class-depth-1">
<a href="Phaser.ArrayList.html">ArrayList</a>
</li>
2014-11-25 00:23:44 +00:00
<li class="class-depth-1">
<a href="Phaser.ArraySet.html">ArraySet</a>
</li>
2014-11-15 20:01:46 +00:00
<li class="class-depth-1">
<a href="Phaser.ArrayUtils.html">ArrayUtils</a>
</li>
2014-10-09 15:12:53 +00:00
<li class="class-depth-1">
<a href="Phaser.AudioSprite.html">AudioSprite</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.BitmapData.html">BitmapData</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.BitmapText.html">BitmapText</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Button.html">Button</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Cache.html">Cache</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Camera.html">Camera</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Canvas.html">Canvas</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Circle.html">Circle</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Color.html">Color</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Device.html">Device</a>
</li>
2014-11-15 20:01:46 +00:00
<li class="class-depth-1">
<a href="Phaser.DOM.html">DOM</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Easing.html">Easing</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Easing.Back.html">Back</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Easing.Bounce.html">Bounce</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Easing.Circular.html">Circular</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Easing.Cubic.html">Cubic</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Easing.Elastic.html">Elastic</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Easing.Exponential.html">Exponential</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Easing.Linear.html">Linear</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Easing.Quartic.html">Quartic</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Easing.Quintic.html">Quintic</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Ellipse.html">Ellipse</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Events.html">Events</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.Filter.html">Filter</a>
</li>
2014-09-09 14:36:56 +00:00
<li class="class-depth-1">
<a href="Phaser.FlexGrid.html">FlexGrid</a>
</li>
<li class="class-depth-1">
<a href="Phaser.FlexLayer.html">FlexLayer</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Frame.html">Frame</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.FrameData.html">FrameData</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Game.html">Game</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.GameObjectCreator.html">GameObjectCreator</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2014-02-05 06:29:17 +00:00
<a href="Phaser.Gamepad.html">Gamepad</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2014-02-05 06:29:17 +00:00
<a href="Phaser.GamepadButton.html">GamepadButton</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Graphics.html">Graphics</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Group.html">Group</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Image.html">Image</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Input.html">Input</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.InputHandler.html">InputHandler</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Key.html">Key</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Keyboard.html">Keyboard</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2014-02-05 06:29:17 +00:00
<a href="Phaser.Line.html">Line</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.LinkedList.html">LinkedList</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Loader.html">Loader</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.LoaderParser.html">LoaderParser</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Math.html">Math</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Mouse.html">Mouse</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.MSPointer.html">MSPointer</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Net.html">Net</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Particle.html">Particle</a>
</li>
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Particles.html">Particles</a>
</li>
2014-10-09 15:12:53 +00:00
<li class="class-depth-2">
<a href="Phaser.Particles.Arcade.html">Arcade</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Physics.html">Physics</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Physics.Arcade.html">Arcade</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Physics.Ninja.html">Ninja</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.AABB.html">AABB</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.Body.html">Body</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.Circle.html">Circle</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.Tile.html">Tile</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Physics.P2.html">P2</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.Body.html">Body</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.BodyDebug.html">BodyDebug</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.CollisionGroup.html">CollisionGroup</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.ContactMaterial.html">ContactMaterial</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.DistanceConstraint.html">DistanceConstraint</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.FixtureList.html">FixtureList</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.GearConstraint.html">GearConstraint</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.InversePointProxy.html">InversePointProxy</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.LockConstraint.html">LockConstraint</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.Material.html">Material</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.PointProxy.html">PointProxy</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.PrismaticConstraint.html">PrismaticConstraint</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.RevoluteConstraint.html">RevoluteConstraint</a>
</li>
2014-09-09 14:36:56 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.RotationalSpring.html">RotationalSpring</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.Spring.html">Spring</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Plugin.html">Plugin</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.PluginManager.html">PluginManager</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Point.html">Point</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Pointer.html">Pointer</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Polygon.html">Polygon</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.QuadTree.html">QuadTree</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Rectangle.html">Rectangle</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.RenderTexture.html">RenderTexture</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.RetroFont.html">RetroFont</a>
</li>
2014-09-09 14:36:56 +00:00
<li class="class-depth-1">
<a href="Phaser.Rope.html">Rope</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.ScaleManager.html">ScaleManager</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Signal.html">Signal</a>
</li>
<li class="class-depth-1">
<a href="Phaser.SignalBinding.html">SignalBinding</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2014-02-05 06:29:17 +00:00
<a href="Phaser.SinglePad.html">SinglePad</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Sound.html">Sound</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.SoundManager.html">SoundManager</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Sprite.html">Sprite</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.SpriteBatch.html">SpriteBatch</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Stage.html">Stage</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.State.html">State</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.StateManager.html">StateManager</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Text.html">Text</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.Tile.html">Tile</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.Tilemap.html">Tilemap</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.TilemapParser.html">TilemapParser</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.Tileset.html">Tileset</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.TileSprite.html">TileSprite</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Time.html">Time</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.Timer.html">Timer</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2014-02-05 06:29:17 +00:00
<a href="Phaser.TimerEvent.html">TimerEvent</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Touch.html">Touch</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Tween.html">Tween</a>
</li>
2014-11-25 00:23:44 +00:00
<li class="class-depth-1">
<a href="Phaser.TweenData.html">TweenData</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.TweenManager.html">TweenManager</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Utils.html">Utils</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Utils.Debug.html">Debug</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.World.html">World</a>
</li>
2014-11-15 20:01:46 +00:00
<li class="class-depth-1">
<a href="PIXI.AbstractFilter.html">AbstractFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.AjaxRequest.html">AjaxRequest</a>
</li>
<li class="class-depth-1">
<a href="PIXI.AlphaMaskFilter.html">AlphaMaskFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.AsciiFilter.html">AsciiFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.AssetLoader.html">AssetLoader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.AtlasLoader.html">AtlasLoader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.BaseTexture.html">BaseTexture</a>
</li>
<li class="class-depth-1">
<a href="PIXI.BitmapFontLoader.html">BitmapFontLoader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.BitmapText.html">BitmapText</a>
</li>
<li class="class-depth-1">
<a href="PIXI.BlurFilter.html">BlurFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.BlurXFilter.html">BlurXFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.BlurYFilter.html">BlurYFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasBuffer.html">CanvasBuffer</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasGraphics.html">CanvasGraphics</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasMaskManager.html">CanvasMaskManager</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasRenderer.html">CanvasRenderer</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CanvasTinter.html">CanvasTinter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Circle.html">Circle</a>
</li>
<li class="class-depth-1">
<a href="PIXI.ColorMatrixFilter.html">ColorMatrixFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.ColorStepFilter.html">ColorStepFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.ComplexPrimitiveShader.html">ComplexPrimitiveShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.ConvolutionFilter.html">ConvolutionFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.CrossHatchFilter.html">CrossHatchFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.DisplacementFilter.html">DisplacementFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.DisplayObject.html">DisplayObject</a>
</li>
<li class="class-depth-1">
<a href="PIXI.DisplayObjectContainer.html">DisplayObjectContainer</a>
</li>
<li class="class-depth-1">
<a href="PIXI.DotScreenFilter.html">DotScreenFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Ellipse.html">Ellipse</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Event.html">Event</a>
</li>
<li class="class-depth-1">
<a href="PIXI.EventTarget.html">EventTarget</a>
</li>
<li class="class-depth-1">
<a href="PIXI.FilterBlock.html">FilterBlock</a>
</li>
<li class="class-depth-1">
<a href="PIXI.FilterTexture.html">FilterTexture</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Graphics.html">Graphics</a>
</li>
<li class="class-depth-1">
<a href="PIXI.GraphicsData.html">GraphicsData</a>
</li>
<li class="class-depth-1">
<a href="PIXI.GrayFilter.html">GrayFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.ImageLoader.html">ImageLoader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.InteractionData.html">InteractionData</a>
</li>
<li class="class-depth-1">
<a href="PIXI.InteractionManager.html">InteractionManager</a>
</li>
<li class="class-depth-1">
<a href="PIXI.InvertFilter.html">InvertFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.JsonLoader.html">JsonLoader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Matrix.html">Matrix</a>
</li>
<li class="class-depth-1">
<a href="PIXI.MovieClip.html">MovieClip</a>
</li>
<li class="class-depth-1">
<a href="PIXI.NoiseFilter.html">NoiseFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.NormalMapFilter.html">NormalMapFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PixelateFilter.html">PixelateFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PIXI.html">PIXI</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PixiFastShader.html">PixiFastShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PixiShader.html">PixiShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Point.html">Point</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Polygon.html">Polygon</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PolyK.html">PolyK</a>
</li>
<li class="class-depth-1">
<a href="PIXI.PrimitiveShader.html">PrimitiveShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Rectangle.html">Rectangle</a>
</li>
<li class="class-depth-1">
<a href="PIXI.RenderTexture.html">RenderTexture</a>
</li>
<li class="class-depth-1">
<a href="PIXI.RGBSplitFilter.html">RGBSplitFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Rope.html">Rope</a>
</li>
<li class="class-depth-1">
<a href="PIXI.RoundedRectangle.html">RoundedRectangle</a>
</li>
<li class="class-depth-1">
<a href="PIXI.SepiaFilter.html">SepiaFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.SmartBlurFilter.html">SmartBlurFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Spine.html">Spine</a>
</li>
<li class="class-depth-1">
<a href="PIXI.SpineLoader.html">SpineLoader</a>
</li>
2014-11-25 00:23:44 +00:00
<li class="class-depth-1">
<a href="PIXI.SpineTextureLoader.html">SpineTextureLoader</a>
</li>
2014-11-15 20:01:46 +00:00
<li class="class-depth-1">
<a href="PIXI.Sprite.html">Sprite</a>
</li>
<li class="class-depth-1">
<a href="PIXI.SpriteBatch.html">SpriteBatch</a>
</li>
<li class="class-depth-1">
<a href="PIXI.SpriteSheetLoader.html">SpriteSheetLoader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Stage.html">Stage</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Strip.html">Strip</a>
</li>
<li class="class-depth-1">
<a href="PIXI.StripShader.html">StripShader</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Text.html">Text</a>
</li>
<li class="class-depth-1">
<a href="PIXI.Texture.html">Texture</a>
</li>
<li class="class-depth-1">
<a href="PIXI.TilingSprite.html">TilingSprite</a>
</li>
<li class="class-depth-1">
<a href="PIXI.TiltShiftFilter.html">TiltShiftFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.TiltShiftXFilter.html">TiltShiftXFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.TiltShiftYFilter.html">TiltShiftYFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.TwistFilter.html">TwistFilter</a>
</li>
<li class="class-depth-1">
<a href="PIXI.VideoTexture.html">VideoTexture</a>
</li>
<li class="class-depth-1">
<a href="PIXI.WebGLBlendModeManager.html">WebGLBlendModeManager</a>
</li>
<li class="class-depth-1">
<a href="PIXI.WebGLFastSpriteBatch.html">WebGLFastSpriteBatch</a>
</li>
<li class="class-depth-1">
<a href="PIXI.WebGLFilterManager.html">WebGLFilterManager</a>
</li>
<li class="class-depth-1">
<a href="PIXI.WebGLRenderer.html">WebGLRenderer</a>
</li>
2013-10-25 15:54:40 +00:00
</ul>
</li>
2014-11-25 00:23:44 +00:00
2014-11-15 20:01:46 +00:00
<li class="dropdown">
2014-11-25 00:23:44 +00:00
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Core<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.Group.html">Group</a></li>
<li class="class-depth-1"><a href="Phaser.World.html">World</a></li>
<li class="class-depth-1"><a href="Phaser.Loader.html">Loader</a></li>
<li class="class-depth-1"><a href="Phaser.Time.html">Time</a></li>
<li class="class-depth-1"><a href="Phaser.Camera.html">Camera</a></li>
<li class="class-depth-1"><a href="Phaser.StateManager.html">State Manager</a></li>
<li class="class-depth-1"><a href="Phaser.TweenManager.html">Tween Manager</a></li>
<li class="class-depth-1"><a href="Phaser.SoundManager.html">Sound Manager</a></li>
<li class="class-depth-1"><a href="Phaser.InputManager.html">Input Manager</a></li>
<li class="class-depth-1"><a href="Phaser.ScaleManager.html">Scale Manager</a></li>
</ul>
</li>
2014-11-15 20:01:46 +00:00
2014-11-25 00:23:44 +00:00
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Game Objects<b class="caret"></b></a>
2014-11-15 20:01:46 +00:00
<ul class="dropdown-menu ">
2014-11-25 00:23:44 +00:00
<li class="class-depth-1"><a href="Phaser.GameObjectFactory.html">Factory (game.add)</a></li>
<li class="class-depth-1"><a href="Phaser.GameObjectCreator.html">Creator (game.make)</a></li>
<li class="class-depth-1"><a href="Phaser.Sprite.html">Sprite</a></li>
<li class="class-depth-1"><a href="Phaser.Image.html">Image</a></li>
<li class="class-depth-1"><a href="Phaser.Sound.html">Sound</a></li>
<li class="class-depth-1"><a href="Phaser.Emitter.html">Emitter</a></li>
<li class="class-depth-1"><a href="Phaser.Text.html">Text</a></li>
<li class="class-depth-1"><a href="Phaser.Tween.html">Tween</a></li>
<li class="class-depth-1"><a href="Phaser.BitmapText.html">BitmapText</a></li>
<li class="class-depth-1"><a href="Phaser.Tilemap.html">Tilemap</a></li>
<li class="class-depth-1"><a href="Phaser.BitmapData.html">BitmapData</a></li>
<li class="class-depth-1"><a href="Phaser.RetroFont.html">RetroFont</a></li>
<li class="class-depth-1"><a href="Phaser.Button.html">Button</a></li>
<li class="class-depth-1"><a href="Phaser.Animation.html">Animation</a></li>
<li class="class-depth-1"><a href="Phaser.Graphics.html">Graphics</a></li>
<li class="class-depth-1"><a href="Phaser.RenderTexture.html">RenderTexture</a></li>
<li class="class-depth-1"><a href="Phaser.TileSprite.html">TileSprite</a></li>
</ul>
</li>
2014-11-15 20:01:46 +00:00
2014-11-25 00:23:44 +00:00
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Geometry<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.Circle.html">Circle</a></li>
<li class="class-depth-1"><a href="Phaser.Rectangle.html">Rectangle</a></li>
<li class="class-depth-1"><a href="Phaser.Point.html">Point</a></li>
<li class="class-depth-1"><a href="Phaser.Line.html">Line</a></li>
<li class="class-depth-1"><a href="Phaser.Ellipse.html">Ellipse</a></li>
<li class="class-depth-1"><a href="Phaser.Polygon.html">Polygon</a></li>
2014-11-15 20:01:46 +00:00
</ul>
</li>
2014-11-25 00:23:44 +00:00
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Physics<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.Physics.Arcade.html">Arcade Physics</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.Arcade.Body.html">Body</a></li>
<li class="class-depth-1"><a href="Phaser.Physics.P2.html">P2 Physics</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.P2.Body.html">Body</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.P2.Spring.html">Spring</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.P2.CollisionGroup.html">CollisionGroup</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.P2.ContactMaterial.html">ContactMaterial</a></li>
<li class="class-depth-1"><a href="Phaser.Physics.Ninja.html">Ninja Physics</a></li>
<li class="class-depth-2"><a href="Phaser.Physics.Body.html">Body</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Input<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="Phaser.InputHandler.html">Input Handler</a></li>
<li class="class-depth-1"><a href="Phaser.Pointer.html">Pointer</a></li>
<li class="class-depth-1"><a href="Phaser.Mouse.html">Mouse</a></li>
<li class="class-depth-1"><a href="Phaser.Keyboard.html">Keyboard</a></li>
<li class="class-depth-1"><a href="Phaser.Key.html">Key</a></li>
<li class="class-depth-1"><a href="Phaser.Gamepad.html">Gamepad</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Community<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li class="class-depth-1"><a href="https://github.com/photonstorm/phaser">Phaser Github</a></li>
<li class="class-depth-1"><a href="http://examples.phaser.io">Phaser Examples</a></li>
<li class="class-depth-1"><a href="https://github.com/photonstorm/phaser-plugins">Phaser Plugins</a></li>
<li class="class-depth-1"><a href="http://www.html5gamedevs.com/forum/14-phaser/">Forum</a></li>
<li class="class-depth-1"><a href="http://stackoverflow.com/questions/tagged/phaser-framework">Stack Overflow</a></li>
<li class="class-depth-1"><a href="https://confirmsubscription.com/h/r/369DE48E3E86AF1E">Newsletter</a></li>
<li class="class-depth-1"><a href="https://twitter.com/photonstorm">Twitter</a></li>
<li class="class-depth-1"><a href="http://www.html5gamedevs.com/topic/4470-official-phaserio-irc-channel-phaserio-on-freenode/">IRC</a></li>
<li class="class-depth-1"><a href="https://www.gittip.com/photonstorm/">GitTip</a></li>
</ul>
</li>
2014-11-15 20:01:46 +00:00
</ul>
</div>
</div>
<div class="row-fluid">
2013-10-25 15:54:40 +00:00
<div class="span12">
<div id="main">
2014-11-15 20:01:46 +00:00
<h1 class="page-title">Source: d:/wamp/www/phaser/src/pixi/display/Sprite.js</h1>
2013-10-25 15:54:40 +00:00
<section>
<article>
<pre class="sunlight-highlight-javascript linenums">/**
2014-11-15 20:01:46 +00:00
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
2013-10-25 15:54:40 +00:00
/**
2014-11-15 20:01:46 +00:00
* The Sprite object is the base for all textured objects that are rendered to the screen
*
* @class Sprite
* @extends DisplayObjectContainer
* @constructor
* @param texture {Texture} The texture for this sprite
*
* A sprite can be created directly from an image like this :
* var sprite = new PIXI.Sprite.fromImage('assets/image.png');
* yourStage.addChild(sprite);
* then obviously don't forget to add it to the stage you have already created
*/
PIXI.Sprite = function(texture)
{
PIXI.DisplayObjectContainer.call( this );
2014-07-10 19:31:11 +00:00
2013-10-25 15:54:40 +00:00
/**
2014-11-15 20:01:46 +00:00
* The anchor sets the origin point of the texture.
* The default is 0,0 this means the texture's origin is the top left
* Setting than anchor to 0.5,0.5 means the textures origin is centered
* Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner
*
* @property anchor
* @type Point
*/
this.anchor = new PIXI.Point();
2013-10-25 15:54:40 +00:00
/**
2014-11-15 20:01:46 +00:00
* The texture that the sprite is using
*
* @property texture
* @type Texture
*/
2014-11-25 00:23:44 +00:00
this.texture = texture || PIXI.Texture.emptyTexture;
2013-10-25 15:54:40 +00:00
/**
2014-11-15 20:01:46 +00:00
* The width of the sprite (this is initially set by the texture)
*
* @property _width
* @type Number
* @private
*/
this._width = 0;
/**
2014-11-15 20:01:46 +00:00
* The height of the sprite (this is initially set by the texture)
*
* @property _height
* @type Number
* @private
*/
this._height = 0;
2014-02-05 06:29:17 +00:00
/**
2014-11-15 20:01:46 +00:00
* The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect.
*
* @property tint
* @type Number
* @default 0xFFFFFF
*/
this.tint = 0xFFFFFF;
2014-02-05 06:29:17 +00:00
/**
2014-11-15 20:01:46 +00:00
* The blend mode to be applied to the sprite. Set to PIXI.blendModes.NORMAL to remove any blend mode.
*
* @property blendMode
* @type Number
* @default PIXI.blendModes.NORMAL;
*/
this.blendMode = PIXI.blendModes.NORMAL;
2014-07-10 19:31:11 +00:00
/**
2014-11-15 20:01:46 +00:00
* The shader that will be used to render the texture to the stage. Set to null to remove a current shader.
*
* @property shader
* @type AbstractFilter
* @default null
*/
this.shader = null;
2014-11-25 00:23:44 +00:00
if(this.texture.baseTexture.hasLoaded)
2014-11-15 20:01:46 +00:00
{
this.onTextureUpdate();
}
else
{
this.texture.on( 'update', this.onTextureUpdate.bind(this) );
}
2014-07-10 19:31:11 +00:00
2014-11-15 20:01:46 +00:00
this.renderable = true;
2014-07-10 19:31:11 +00:00
2014-11-15 20:01:46 +00:00
};
2014-07-10 19:31:11 +00:00
2014-11-15 20:01:46 +00:00
// constructor
PIXI.Sprite.prototype = Object.create( PIXI.DisplayObjectContainer.prototype );
PIXI.Sprite.prototype.constructor = PIXI.Sprite;
2013-11-01 18:16:52 +00:00
2014-11-15 20:01:46 +00:00
/**
* The width of the sprite, setting this will actually modify the scale to achieve the value set
*
* @property width
* @type Number
*/
Object.defineProperty(PIXI.Sprite.prototype, 'width', {
get: function() {
return this.scale.x * this.texture.frame.width;
},
set: function(value) {
this.scale.x = value / this.texture.frame.width;
this._width = value;
}
});
2014-02-05 06:29:17 +00:00
2014-11-15 20:01:46 +00:00
/**
* The height of the sprite, setting this will actually modify the scale to achieve the value set
*
* @property height
* @type Number
*/
Object.defineProperty(PIXI.Sprite.prototype, 'height', {
get: function() {
return this.scale.y * this.texture.frame.height;
},
set: function(value) {
this.scale.y = value / this.texture.frame.height;
this._height = value;
}
});
2014-07-10 19:31:11 +00:00
2014-11-15 20:01:46 +00:00
/**
* Sets the texture of the sprite
*
* @method setTexture
* @param texture {Texture} The PIXI texture that is displayed by the sprite
*/
PIXI.Sprite.prototype.setTexture = function(texture)
{
this.texture = texture;
this.cachedTint = 0xFFFFFF;
2013-10-25 15:54:40 +00:00
};
2014-11-15 20:01:46 +00:00
/**
* When the texture is updated, this event will fire to update the scale and frame
*
* @method onTextureUpdate
* @param event
* @private
*/
PIXI.Sprite.prototype.onTextureUpdate = function()
{
// so if _width is 0 then width was not set..
if(this._width)this.scale.x = this._width / this.texture.frame.width;
if(this._height)this.scale.y = this._height / this.texture.frame.height;
//this.updateFrame = true;
};
2013-10-25 15:54:40 +00:00
/**
2014-11-15 20:01:46 +00:00
* Returns the bounds of the Sprite as a rectangle. The bounds calculation takes the worldTransform into account.
2013-10-25 15:54:40 +00:00
*
2014-11-15 20:01:46 +00:00
* @method getBounds
* @param matrix {Matrix} the transformation matrix of the sprite
* @return {Rectangle} the framing rectangle
2013-10-25 15:54:40 +00:00
*/
2014-11-15 20:01:46 +00:00
PIXI.Sprite.prototype.getBounds = function(matrix)
{
var width = this.texture.frame.width;
var height = this.texture.frame.height;
2014-02-05 06:29:17 +00:00
2014-11-15 20:01:46 +00:00
var w0 = width * (1-this.anchor.x);
var w1 = width * -this.anchor.x;
2014-03-24 12:41:45 +00:00
2014-11-15 20:01:46 +00:00
var h0 = height * (1-this.anchor.y);
var h1 = height * -this.anchor.y;
2014-02-05 06:29:17 +00:00
2014-11-15 20:01:46 +00:00
var worldTransform = matrix || this.worldTransform ;
2014-11-15 20:01:46 +00:00
var a = worldTransform.a;
var b = worldTransform.b;
var c = worldTransform.c;
var d = worldTransform.d;
var tx = worldTransform.tx;
var ty = worldTransform.ty;
2013-10-25 15:54:40 +00:00
2014-11-15 20:01:46 +00:00
var maxX = -Infinity;
var maxY = -Infinity;
2013-10-25 15:54:40 +00:00
2014-11-15 20:01:46 +00:00
var minX = Infinity;
var minY = Infinity;
2013-10-25 15:54:40 +00:00
2014-11-25 00:23:44 +00:00
if(b === 0 && c === 0)
{
// scale may be negative!
if(a &lt; 0)a *= -1;
if(d &lt; 0)d *= -1;
// this means there is no rotation going on right? RIGHT?
// if thats the case then we can avoid checking the bound values! yay
minX = a * w1 + tx;
maxX = a * w0 + tx;
minY = d * h1 + ty;
maxY = d * h0 + ty;
}
else
{
var x1 = a * w1 + c * h1 + tx;
var y1 = d * h1 + b * w1 + ty;
var x2 = a * w0 + c * h1 + tx;
var y2 = d * h1 + b * w0 + ty;
var x3 = a * w0 + c * h0 + tx;
var y3 = d * h0 + b * w0 + ty;
var x4 = a * w1 + c * h0 + tx;
var y4 = d * h0 + b * w1 + ty;
2013-11-01 18:16:52 +00:00
2014-11-25 00:23:44 +00:00
minX = x1 &lt; minX ? x1 : minX;
minX = x2 &lt; minX ? x2 : minX;
minX = x3 &lt; minX ? x3 : minX;
minX = x4 &lt; minX ? x4 : minX;
minY = y1 &lt; minY ? y1 : minY;
minY = y2 &lt; minY ? y2 : minY;
minY = y3 &lt; minY ? y3 : minY;
minY = y4 &lt; minY ? y4 : minY;
maxX = x1 > maxX ? x1 : maxX;
maxX = x2 > maxX ? x2 : maxX;
maxX = x3 > maxX ? x3 : maxX;
maxX = x4 > maxX ? x4 : maxX;
maxY = y1 > maxY ? y1 : maxY;
maxY = y2 > maxY ? y2 : maxY;
maxY = y3 > maxY ? y3 : maxY;
maxY = y4 > maxY ? y4 : maxY;
}
2014-11-15 20:01:46 +00:00
var bounds = this._bounds;
2013-10-25 15:54:40 +00:00
2014-11-15 20:01:46 +00:00
bounds.x = minX;
bounds.width = maxX - minX;
2013-10-25 15:54:40 +00:00
2014-11-15 20:01:46 +00:00
bounds.y = minY;
bounds.height = maxY - minY;
2013-10-25 15:54:40 +00:00
2014-11-15 20:01:46 +00:00
// store a reference so that if this function gets called again in the render cycle we do not have to recalculate
this._currentBounds = bounds;
2014-11-15 20:01:46 +00:00
return bounds;
};
2013-10-25 15:54:40 +00:00
/**
2014-11-15 20:01:46 +00:00
* Renders the object using the WebGL renderer
2013-10-25 15:54:40 +00:00
*
2014-11-15 20:01:46 +00:00
* @method _renderWebGL
* @param renderSession {RenderSession}
* @private
2013-10-25 15:54:40 +00:00
*/
2014-11-15 20:01:46 +00:00
PIXI.Sprite.prototype._renderWebGL = function(renderSession)
{
// if the sprite is not visible or the alpha is 0 then no need to render this element
2014-11-25 00:23:44 +00:00
if (!this.visible || this.alpha &lt;= 0 || !this.renderable) return;
2013-10-25 15:54:40 +00:00
2014-11-15 20:01:46 +00:00
var i,j;
2014-11-15 20:01:46 +00:00
// do a quick check to see if this element has a mask or a filter.
if(this._mask || this._filters)
{
2014-11-15 20:01:46 +00:00
var spriteBatch = renderSession.spriteBatch;
2013-10-25 15:54:40 +00:00
2014-11-15 20:01:46 +00:00
// push filter first as we need to ensure the stencil buffer is correct for any masking
if(this._filters)
{
spriteBatch.flush();
renderSession.filterManager.pushFilter(this._filterBlock);
}
2013-10-25 15:54:40 +00:00
2014-11-15 20:01:46 +00:00
if(this._mask)
{
spriteBatch.stop();
renderSession.maskManager.pushMask(this.mask, renderSession);
spriteBatch.start();
}
2013-10-25 15:54:40 +00:00
2014-11-15 20:01:46 +00:00
// add this sprite to the batch
spriteBatch.render(this);
2014-07-18 11:45:51 +00:00
2014-11-15 20:01:46 +00:00
// now loop through the children and make sure they get rendered
for(i=0,j=this.children.length; i&lt;j; i++)
{
this.children[i]._renderWebGL(renderSession);
}
2014-07-10 19:31:11 +00:00
2014-11-15 20:01:46 +00:00
// time to stop the sprite batch as either a mask element or a filter draw will happen next
spriteBatch.stop();
2014-07-10 19:31:11 +00:00
2014-11-15 20:01:46 +00:00
if(this._mask)renderSession.maskManager.popMask(this._mask, renderSession);
if(this._filters)renderSession.filterManager.popFilter();
2014-10-09 15:12:53 +00:00
2014-11-15 20:01:46 +00:00
spriteBatch.start();
2013-10-25 15:54:40 +00:00
}
else
{
2014-11-15 20:01:46 +00:00
renderSession.spriteBatch.render(this);
2014-11-15 20:01:46 +00:00
// simple render children!
for(i=0,j=this.children.length; i&lt;j; i++)
{
this.children[i]._renderWebGL(renderSession);
2013-10-25 15:54:40 +00:00
}
2014-07-10 19:31:11 +00:00
2014-07-18 11:45:51 +00:00
}
2014-07-10 19:31:11 +00:00
};
/**
2014-11-15 20:01:46 +00:00
* Renders the object using the Canvas renderer
2014-07-10 19:31:11 +00:00
*
2014-11-15 20:01:46 +00:00
* @method _renderCanvas
* @param renderSession {RenderSession}
* @private
2014-07-10 19:31:11 +00:00
*/
2014-11-15 20:01:46 +00:00
PIXI.Sprite.prototype._renderCanvas = function(renderSession)
{
// If the sprite is not visible or the alpha is 0 then no need to render this element
2014-11-25 00:23:44 +00:00
if (this.visible === false || this.alpha === 0 || this.renderable === false || this.texture.crop.width &lt;= 0 || this.texture.crop.height &lt;= 0) return;
2014-07-10 19:31:11 +00:00
2014-11-15 20:01:46 +00:00
if (this.blendMode !== renderSession.currentBlendMode)
2014-10-09 15:12:53 +00:00
{
2014-11-15 20:01:46 +00:00
renderSession.currentBlendMode = this.blendMode;
renderSession.context.globalCompositeOperation = PIXI.blendModesCanvas[renderSession.currentBlendMode];
2014-10-09 15:12:53 +00:00
}
2014-07-10 19:31:11 +00:00
2014-11-15 20:01:46 +00:00
if (this._mask)
2014-07-10 19:31:11 +00:00
{
2014-11-15 20:01:46 +00:00
renderSession.maskManager.pushMask(this._mask, renderSession);
2014-07-10 19:31:11 +00:00
}
2014-10-22 20:49:44 +00:00
2014-11-15 20:01:46 +00:00
// Ignore null sources
if (this.texture.valid)
2014-07-10 19:31:11 +00:00
{
2014-11-15 20:01:46 +00:00
var resolution = this.texture.baseTexture.resolution / renderSession.resolution;
2014-07-10 19:31:11 +00:00
2014-11-15 20:01:46 +00:00
renderSession.context.globalAlpha = this.worldAlpha;
2013-10-25 15:54:40 +00:00
2014-11-15 20:01:46 +00:00
// Allow for pixel rounding
if (renderSession.roundPixels)
2014-07-10 19:31:11 +00:00
{
2014-11-15 20:01:46 +00:00
renderSession.context.setTransform(
this.worldTransform.a,
this.worldTransform.b,
this.worldTransform.c,
this.worldTransform.d,
(this.worldTransform.tx* renderSession.resolution) | 0,
(this.worldTransform.ty* renderSession.resolution) | 0);
2014-07-10 19:31:11 +00:00
}
else
{
2014-11-15 20:01:46 +00:00
renderSession.context.setTransform(
this.worldTransform.a,
this.worldTransform.b,
this.worldTransform.c,
this.worldTransform.d,
this.worldTransform.tx * renderSession.resolution,
this.worldTransform.ty * renderSession.resolution);
}
2014-07-10 19:31:11 +00:00
2014-11-15 20:01:46 +00:00
// If smoothingEnabled is supported and we need to change the smoothing property for this texture
if (renderSession.smoothProperty && renderSession.scaleMode !== this.texture.baseTexture.scaleMode)
{
renderSession.scaleMode = this.texture.baseTexture.scaleMode;
renderSession.context[renderSession.smoothProperty] = (renderSession.scaleMode === PIXI.scaleModes.LINEAR);
}
2014-02-05 06:29:17 +00:00
2014-11-15 20:01:46 +00:00
// If the texture is trimmed we offset by the trim x/y, otherwise we use the frame dimensions
var dx = (this.texture.trim) ? this.texture.trim.x - this.anchor.x * this.texture.trim.width : this.anchor.x * -this.texture.frame.width;
var dy = (this.texture.trim) ? this.texture.trim.y - this.anchor.y * this.texture.trim.height : this.anchor.y * -this.texture.frame.height;
2014-11-15 20:01:46 +00:00
if (this.tint !== 0xFFFFFF)
{
if (this.cachedTint !== this.tint)
{
this.cachedTint = this.tint;
2014-11-15 20:01:46 +00:00
// TODO clean up caching - how to clean up the caches?
this.tintedTexture = PIXI.CanvasTinter.getTintedTexture(this, this.tint);
}
2014-11-15 20:01:46 +00:00
renderSession.context.drawImage(
this.tintedTexture,
0,
0,
this.texture.crop.width,
this.texture.crop.height,
dx / resolution,
dy / resolution,
this.texture.crop.width / resolution,
this.texture.crop.height / resolution);
}
else
{
renderSession.context.drawImage(
this.texture.baseTexture.source,
this.texture.crop.x,
this.texture.crop.y,
this.texture.crop.width,
this.texture.crop.height,
dx / resolution,
dy / resolution,
this.texture.crop.width / resolution,
this.texture.crop.height / resolution);
}
2014-07-10 19:31:11 +00:00
}
2014-11-15 20:01:46 +00:00
// OVERWRITE
for (var i = 0, j = this.children.length; i &lt; j; i++)
2013-10-25 15:54:40 +00:00
{
2014-11-15 20:01:46 +00:00
this.children[i]._renderCanvas(renderSession);
2013-10-25 15:54:40 +00:00
}
2014-11-15 20:01:46 +00:00
if (this._mask)
2013-10-25 15:54:40 +00:00
{
2014-11-15 20:01:46 +00:00
renderSession.maskManager.popMask(renderSession);
2013-10-25 15:54:40 +00:00
}
2014-11-15 20:01:46 +00:00
};
2013-10-25 15:54:40 +00:00
2014-11-15 20:01:46 +00:00
// some helper functions..
2013-10-25 15:54:40 +00:00
2014-11-15 20:01:46 +00:00
/**
*
* Helper function that creates a sprite that will contain a texture from the TextureCache based on the frameId
* The frame ids are created when a Texture packer file has been loaded
*
* @method fromFrame
* @static
* @param frameId {String} The frame Id of the texture in the cache
* @return {Sprite} A new Sprite using a texture from the texture cache matching the frameId
*/
PIXI.Sprite.fromFrame = function(frameId)
{
var texture = PIXI.TextureCache[frameId];
if(!texture) throw new Error('The frameId "' + frameId + '" does not exist in the texture cache' + this);
return new PIXI.Sprite(texture);
2013-11-01 18:16:52 +00:00
};
2013-10-25 15:54:40 +00:00
/**
2014-11-15 20:01:46 +00:00
*
* Helper function that creates a sprite that will contain a texture based on an image url
* If the image is not in the texture cache it will be loaded
*
* @method fromImage
* @static
* @param imageId {String} The image url of the texture
* @return {Sprite} A new Sprite using a texture from the texture cache matching the image id
*/
PIXI.Sprite.fromImage = function(imageId, crossorigin, scaleMode)
{
var texture = PIXI.Texture.fromImage(imageId, crossorigin, scaleMode);
return new PIXI.Sprite(texture);
2013-11-01 18:16:52 +00:00
};
2013-10-25 15:54:40 +00:00
</pre>
</article>
</section>
</div>
<div class="clearfix"></div>
<footer>
<span class="copyright">
2014-02-05 06:29:17 +00:00
Phaser Copyright © 2012-2014 Photon Storm Ltd.
2013-10-25 15:54:40 +00:00
</span>
<br />
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
2014-11-25 00:23:44 +00:00
on Tue Nov 25 2014 00:17:17 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
2013-10-25 15:54:40 +00:00
</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( {
2014-04-10 22:13:43 +00:00
anchorName : function(i, heading, prefix) {
return $(heading).attr("id") || ( prefix + i );
},
2013-10-25 15:54:40 +00:00
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>