PageRenderTime 56ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/org/flixel/FlxCamera.as

https://github.com/taitehughes/flixel
ActionScript | 706 lines | 376 code | 47 blank | 283 comment | 67 complexity | 79ccb9cb77d38b4e946be8c674cb495d MD5 | raw file
  1. package org.flixel
  2. {
  3. import flash.display.Bitmap;
  4. import flash.display.BitmapData;
  5. import flash.display.Sprite;
  6. import flash.geom.ColorTransform;
  7. import flash.geom.Point;
  8. import flash.geom.Rectangle;
  9. /**
  10. * The camera class is used to display the game's visuals in the Flash player.
  11. * By default one camera is created automatically, that is the same size as the Flash player.
  12. * You can add more cameras or even replace the main camera using utilities in <code>FlxG</code>.
  13. *
  14. * @author Adam Atomic
  15. */
  16. public class FlxCamera extends FlxBasic
  17. {
  18. /**
  19. * Camera "follow" style preset: camera has no deadzone, just tracks the focus object directly.
  20. */
  21. static public const STYLE_LOCKON:uint = 0;
  22. /**
  23. * Camera "follow" style preset: camera deadzone is narrow but tall.
  24. */
  25. static public const STYLE_PLATFORMER:uint = 1;
  26. /**
  27. * Camera "follow" style preset: camera deadzone is a medium-size square around the focus object.
  28. */
  29. static public const STYLE_TOPDOWN:uint = 2;
  30. /**
  31. * Camera "follow" style preset: camera deadzone is a small square around the focus object.
  32. */
  33. static public const STYLE_TOPDOWN_TIGHT:uint = 3;
  34. /**
  35. * Camera "shake" effect preset: shake camera on both the X and Y axes.
  36. */
  37. static public const SHAKE_BOTH_AXES:uint = 0;
  38. /**
  39. * Camera "shake" effect preset: shake camera on the X axis only.
  40. */
  41. static public const SHAKE_HORIZONTAL_ONLY:uint = 1;
  42. /**
  43. * Camera "shake" effect preset: shake camera on the Y axis only.
  44. */
  45. static public const SHAKE_VERTICAL_ONLY:uint = 2;
  46. /**
  47. * While you can alter the zoom of each camera after the fact,
  48. * this variable determines what value the camera will start at when created.
  49. */
  50. static public var defaultZoom:Number;
  51. /**
  52. * The X position of this camera's display. Zoom does NOT affect this number.
  53. * Measured in pixels from the left side of the flash window.
  54. */
  55. public var x:Number;
  56. /**
  57. * The Y position of this camera's display. Zoom does NOT affect this number.
  58. * Measured in pixels from the top of the flash window.
  59. */
  60. public var y:Number;
  61. /**
  62. * How wide the camera display is, in game pixels.
  63. */
  64. public var width:uint;
  65. /**
  66. * How tall the camera display is, in game pixels.
  67. */
  68. public var height:uint;
  69. /**
  70. * Tells the camera to follow this <code>FlxObject</code> object around.
  71. */
  72. public var target:FlxObject;
  73. /**
  74. * You can assign a "dead zone" to the camera in order to better control its movement.
  75. * The camera will always keep the focus object inside the dead zone,
  76. * unless it is bumping up against the bounds rectangle's edges.
  77. * The deadzone's coordinates are measured from the camera's upper left corner in game pixels.
  78. * For rapid prototyping, you can use the preset deadzones (e.g. <code>STYLE_PLATFORMER</code>) with <code>follow()</code>.
  79. */
  80. public var deadzone:FlxRect;
  81. /**
  82. * The edges of the camera's range, i.e. where to stop scrolling.
  83. * Measured in game pixels and world coordinates.
  84. */
  85. public var bounds:FlxRect;
  86. /**
  87. * Stores the basic parallax scrolling values.
  88. */
  89. public var scroll:FlxPoint;
  90. /**
  91. * The actual bitmap data of the camera display itself.
  92. */
  93. public var buffer:BitmapData;
  94. /**
  95. * The natural background color of the camera. Defaults to FlxG.bgColor.
  96. * NOTE: can be transparent for crazy FX!
  97. */
  98. public var bgColor:uint;
  99. /**
  100. * Sometimes it's easier to just work with a <code>FlxSprite</code> than it is to work
  101. * directly with the <code>BitmapData</code> buffer. This sprite reference will
  102. * allow you to do exactly that.
  103. */
  104. public var screen:FlxSprite;
  105. /**
  106. * Indicates how far the camera is zoomed in.
  107. */
  108. protected var _zoom:Number;
  109. /**
  110. * Internal, to help avoid costly allocations.
  111. */
  112. protected var _point:FlxPoint;
  113. /**
  114. * Internal, help with color transforming the flash bitmap.
  115. */
  116. protected var _color:uint;
  117. /**
  118. * Internal, used to render buffer to screen space.
  119. */
  120. protected var _flashBitmap:Bitmap;
  121. /**
  122. * Internal, used to render buffer to screen space.
  123. */
  124. internal var _flashSprite:Sprite;
  125. /**
  126. * Internal, used to render buffer to screen space.
  127. */
  128. internal var _flashOffsetX:Number;
  129. /**
  130. * Internal, used to render buffer to screen space.
  131. */
  132. internal var _flashOffsetY:Number;
  133. /**
  134. * Internal, used to render buffer to screen space.
  135. */
  136. protected var _flashRect:Rectangle;
  137. /**
  138. * Internal, used to render buffer to screen space.
  139. */
  140. protected var _flashPoint:Point;
  141. /**
  142. * Internal, used to control the "flash" special effect.
  143. */
  144. protected var _fxFlashColor:uint;
  145. /**
  146. * Internal, used to control the "flash" special effect.
  147. */
  148. protected var _fxFlashDuration:Number;
  149. /**
  150. * Internal, used to control the "flash" special effect.
  151. */
  152. protected var _fxFlashComplete:Function;
  153. /**
  154. * Internal, used to control the "flash" special effect.
  155. */
  156. protected var _fxFlashAlpha:Number;
  157. /**
  158. * Internal, used to control the "fade" special effect.
  159. */
  160. protected var _fxFadeColor:uint;
  161. /**
  162. * Internal, used to control the "fade" special effect.
  163. */
  164. protected var _fxFadeDuration:Number;
  165. /**
  166. * Internal, used to control the "fade" special effect.
  167. */
  168. protected var _fxFadeComplete:Function;
  169. /**
  170. * Internal, used to control the "fade" special effect.
  171. */
  172. protected var _fxFadeAlpha:Number;
  173. /**
  174. * Internal, used to control the "shake" special effect.
  175. */
  176. protected var _fxShakeIntensity:Number;
  177. /**
  178. * Internal, used to control the "shake" special effect.
  179. */
  180. protected var _fxShakeDuration:Number;
  181. /**
  182. * Internal, used to control the "shake" special effect.
  183. */
  184. protected var _fxShakeComplete:Function;
  185. /**
  186. * Internal, used to control the "shake" special effect.
  187. */
  188. protected var _fxShakeOffset:FlxPoint;
  189. /**
  190. * Internal, used to control the "shake" special effect.
  191. */
  192. protected var _fxShakeDirection:uint;
  193. /**
  194. * Internal helper variable for doing better wipes/fills between renders.
  195. */
  196. protected var _fill:BitmapData;
  197. /**
  198. * Instantiates a new camera at the specified location, with the specified size and zoom level.
  199. *
  200. * @param X X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
  201. * @param Y Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
  202. * @param Width The width of the camera display in pixels.
  203. * @param Height The height of the camera display in pixels.
  204. * @param Zoom The initial zoom level of the camera. A zoom level of 2 will make all pixels display at 2x resolution.
  205. */
  206. public function FlxCamera(X:int,Y:int,Width:int,Height:int,Zoom:Number=0)
  207. {
  208. x = X;
  209. y = Y;
  210. width = Width;
  211. height = Height;
  212. target = null;
  213. deadzone = null;
  214. scroll = new FlxPoint();
  215. _point = new FlxPoint();
  216. bounds = null;
  217. screen = new FlxSprite();
  218. screen.makeGraphic(width,height,0,true);
  219. screen.setOriginToCorner();
  220. buffer = screen.pixels;
  221. bgColor = FlxG.bgColor;
  222. _color = 0xffffff;
  223. _flashBitmap = new Bitmap(buffer);
  224. _flashBitmap.x = -width*0.5;
  225. _flashBitmap.y = -height*0.5;
  226. _flashSprite = new Sprite();
  227. zoom = Zoom; //sets the scale of flash sprite, which in turn loads flashoffset values
  228. _flashOffsetX = width*0.5*zoom;
  229. _flashOffsetY = height*0.5*zoom;
  230. _flashSprite.x = x + _flashOffsetX;
  231. _flashSprite.y = y + _flashOffsetY;
  232. _flashSprite.addChild(_flashBitmap);
  233. _flashRect = new Rectangle(0,0,width,height);
  234. _flashPoint = new Point();
  235. _fxFlashColor = 0;
  236. _fxFlashDuration = 0.0;
  237. _fxFlashComplete = null;
  238. _fxFlashAlpha = 0.0;
  239. _fxFadeColor = 0;
  240. _fxFadeDuration = 0.0;
  241. _fxFadeComplete = null;
  242. _fxFadeAlpha = 0.0;
  243. _fxShakeIntensity = 0.0;
  244. _fxShakeDuration = 0.0;
  245. _fxShakeComplete = null;
  246. _fxShakeOffset = new FlxPoint();
  247. _fxShakeDirection = 0;
  248. _fill = new BitmapData(width,height,true,0);
  249. }
  250. /**
  251. * Clean up memory.
  252. */
  253. override public function destroy():void
  254. {
  255. screen.destroy();
  256. screen = null;
  257. target = null;
  258. scroll = null;
  259. deadzone = null;
  260. bounds = null;
  261. buffer = null;
  262. _flashBitmap = null;
  263. _flashRect = null;
  264. _flashPoint = null;
  265. _fxFlashComplete = null;
  266. _fxFadeComplete = null;
  267. _fxShakeComplete = null;
  268. _fxShakeOffset = null;
  269. _fill = null;
  270. }
  271. /**
  272. * Updates the camera scroll as well as special effects like screen-shake or fades.
  273. */
  274. override public function update():void
  275. {
  276. //Either follow the object closely,
  277. //or doublecheck our deadzone and update accordingly.
  278. if(target != null)
  279. {
  280. if(deadzone == null)
  281. focusOn(target.getMidpoint(_point));
  282. else
  283. {
  284. var edge:Number;
  285. var targetX:Number = target.x + ((target.x > 0)?0.0000001:-0.0000001);
  286. var targetY:Number = target.y + ((target.y > 0)?0.0000001:-0.0000001);
  287. edge = targetX - deadzone.x;
  288. if(scroll.x > edge)
  289. scroll.x = edge;
  290. edge = targetX + target.width - deadzone.x - deadzone.width;
  291. if(scroll.x < edge)
  292. scroll.x = edge;
  293. edge = targetY - deadzone.y;
  294. if(scroll.y > edge)
  295. scroll.y = edge;
  296. edge = targetY + target.height - deadzone.y - deadzone.height;
  297. if(scroll.y < edge)
  298. scroll.y = edge;
  299. }
  300. }
  301. //Make sure we didn't go outside the camera's bounds
  302. if(bounds != null)
  303. {
  304. if(scroll.x < bounds.left)
  305. scroll.x = bounds.left;
  306. if(scroll.x > bounds.right - width)
  307. scroll.x = bounds.right - width;
  308. if(scroll.y < bounds.top)
  309. scroll.y = bounds.top;
  310. if(scroll.y > bounds.bottom - height)
  311. scroll.y = bounds.bottom - height;
  312. }
  313. //Update the "flash" special effect
  314. if(_fxFlashAlpha > 0.0)
  315. {
  316. _fxFlashAlpha -= FlxG.elapsed/_fxFlashDuration;
  317. if((_fxFlashAlpha <= 0) && (_fxFlashComplete != null))
  318. _fxFlashComplete();
  319. }
  320. //Update the "fade" special effect
  321. if((_fxFadeAlpha > 0.0) && (_fxFadeAlpha < 1.0))
  322. {
  323. _fxFadeAlpha += FlxG.elapsed/_fxFadeDuration;
  324. if(_fxFadeAlpha >= 1.0)
  325. {
  326. _fxFadeAlpha = 1.0;
  327. if(_fxFadeComplete != null)
  328. _fxFadeComplete();
  329. }
  330. }
  331. //Update the "shake" special effect
  332. if(_fxShakeDuration > 0)
  333. {
  334. _fxShakeDuration -= FlxG.elapsed;
  335. if(_fxShakeDuration <= 0)
  336. {
  337. _fxShakeOffset.make();
  338. if(_fxShakeComplete != null)
  339. _fxShakeComplete();
  340. }
  341. else
  342. {
  343. if((_fxShakeDirection == SHAKE_BOTH_AXES) || (_fxShakeDirection == SHAKE_HORIZONTAL_ONLY))
  344. _fxShakeOffset.x = (FlxG.random()*_fxShakeIntensity*width*2-_fxShakeIntensity*width)*_zoom;
  345. if((_fxShakeDirection == SHAKE_BOTH_AXES) || (_fxShakeDirection == SHAKE_VERTICAL_ONLY))
  346. _fxShakeOffset.y = (FlxG.random()*_fxShakeIntensity*height*2-_fxShakeIntensity*height)*_zoom;
  347. }
  348. }
  349. }
  350. /**
  351. * Tells this camera object what <code>FlxObject</code> to track.
  352. *
  353. * @param Target The object you want the camera to track. Set to null to not follow anything.
  354. * @param Style Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling <code>follow()</code>.
  355. */
  356. public function follow(Target:FlxObject, Style:uint=STYLE_LOCKON):void
  357. {
  358. target = Target;
  359. var helper:Number;
  360. switch(Style)
  361. {
  362. case STYLE_PLATFORMER:
  363. var w:Number = width/8;
  364. var h:Number = height/3;
  365. deadzone = new FlxRect((width-w)/2,(height-h)/2 - h*0.25,w,h);
  366. break;
  367. case STYLE_TOPDOWN:
  368. helper = FlxU.max(width,height)/4;
  369. deadzone = new FlxRect((width-helper)/2,(height-helper)/2,helper,helper);
  370. break;
  371. case STYLE_TOPDOWN_TIGHT:
  372. helper = FlxU.max(width,height)/8;
  373. deadzone = new FlxRect((width-helper)/2,(height-helper)/2,helper,helper);
  374. break;
  375. case STYLE_LOCKON:
  376. default:
  377. deadzone = null;
  378. break;
  379. }
  380. }
  381. /**
  382. * Move the camera focus to this location instantly.
  383. *
  384. * @param Point Where you want the camera to focus.
  385. */
  386. public function focusOn(Point:FlxPoint):void
  387. {
  388. Point.x += (Point.x > 0)?0.0000001:-0.0000001;
  389. Point.y += (Point.y > 0)?0.0000001:-0.0000001;
  390. scroll.make(Point.x - width*0.5,Point.y - height*0.5);
  391. }
  392. /**
  393. * Specify the boundaries of the level or where the camera is allowed to move.
  394. *
  395. * @param X The smallest X value of your level (usually 0).
  396. * @param Y The smallest Y value of your level (usually 0).
  397. * @param Width The largest X value of your level (usually the level width).
  398. * @param Height The largest Y value of your level (usually the level height).
  399. * @param UpdateWorld Whether the global quad-tree's dimensions should be updated to match (default: false).
  400. */
  401. public function setBounds(X:Number=0, Y:Number=0, Width:Number=0, Height:Number=0, UpdateWorld:Boolean=false):void
  402. {
  403. if(bounds == null)
  404. bounds = new FlxRect();
  405. bounds.make(X,Y,Width,Height);
  406. if(UpdateWorld)
  407. FlxG.worldBounds.copyFrom(bounds);
  408. update();
  409. }
  410. /**
  411. * The screen is filled with this color and gradually returns to normal.
  412. *
  413. * @param Color The color you want to use.
  414. * @param Duration How long it takes for the flash to fade.
  415. * @param OnComplete A function you want to run when the flash finishes.
  416. * @param Force Force the effect to reset.
  417. */
  418. public function flash(Color:uint=0xffffffff, Duration:Number=1, OnComplete:Function=null, Force:Boolean=false):void
  419. {
  420. if(!Force && (_fxFlashAlpha > 0.0))
  421. return;
  422. _fxFlashColor = Color;
  423. if(Duration <= 0)
  424. Duration = Number.MIN_VALUE;
  425. _fxFlashDuration = Duration;
  426. _fxFlashComplete = OnComplete;
  427. _fxFlashAlpha = 1.0;
  428. }
  429. /**
  430. * The screen is gradually filled with this color.
  431. *
  432. * @param Color The color you want to use.
  433. * @param Duration How long it takes for the fade to finish.
  434. * @param OnComplete A function you want to run when the fade finishes.
  435. * @param Force Force the effect to reset.
  436. */
  437. public function fade(Color:uint=0xff000000, Duration:Number=1, OnComplete:Function=null, Force:Boolean=false):void
  438. {
  439. if(!Force && (_fxFadeAlpha > 0.0))
  440. return;
  441. _fxFadeColor = Color;
  442. if(Duration <= 0)
  443. Duration = Number.MIN_VALUE;
  444. _fxFadeDuration = Duration;
  445. _fxFadeComplete = OnComplete;
  446. _fxFadeAlpha = Number.MIN_VALUE;
  447. }
  448. /**
  449. * A simple screen-shake effect.
  450. *
  451. * @param Intensity Percentage of screen size representing the maximum distance that the screen can move while shaking.
  452. * @param Duration The length in seconds that the shaking effect should last.
  453. * @param OnComplete A function you want to run when the shake effect finishes.
  454. * @param Force Force the effect to reset (default = true, unlike flash() and fade()!).
  455. * @param Direction Whether to shake on both axes, just up and down, or just side to side (use class constants SHAKE_BOTH_AXES, SHAKE_VERTICAL_ONLY, or SHAKE_HORIZONTAL_ONLY).
  456. */
  457. public function shake(Intensity:Number=0.05, Duration:Number=0.5, OnComplete:Function=null, Force:Boolean=true, Direction:uint=SHAKE_BOTH_AXES):void
  458. {
  459. if(!Force && ((_fxShakeOffset.x != 0) || (_fxShakeOffset.y != 0)))
  460. return;
  461. _fxShakeIntensity = Intensity;
  462. _fxShakeDuration = Duration;
  463. _fxShakeComplete = OnComplete;
  464. _fxShakeDirection = Direction;
  465. _fxShakeOffset.make();
  466. }
  467. /**
  468. * Just turns off all the camera effects instantly.
  469. */
  470. public function stopFX():void
  471. {
  472. _fxFlashAlpha = 0.0;
  473. _fxFadeAlpha = 0.0;
  474. _fxShakeDuration = 0;
  475. _flashSprite.x = x + width*0.5;
  476. _flashSprite.y = y + height*0.5;
  477. }
  478. /**
  479. * Copy the bounds, focus object, and deadzone info from an existing camera.
  480. *
  481. * @param Camera The camera you want to copy from.
  482. *
  483. * @return A reference to this <code>FlxCamera</code> object.
  484. */
  485. public function copyFrom(Camera:FlxCamera):FlxCamera
  486. {
  487. if(Camera.bounds == null)
  488. bounds = null;
  489. else
  490. {
  491. if(bounds == null)
  492. bounds = new FlxRect();
  493. bounds.copyFrom(Camera.bounds);
  494. }
  495. target = Camera.target;
  496. if(target != null)
  497. {
  498. if(Camera.deadzone == null)
  499. deadzone = null;
  500. else
  501. {
  502. if(deadzone == null)
  503. deadzone = new FlxRect();
  504. deadzone.copyFrom(Camera.deadzone);
  505. }
  506. }
  507. return this;
  508. }
  509. /**
  510. * The zoom level of this camera. 1 = 1:1, 2 = 2x zoom, etc.
  511. */
  512. public function get zoom():Number
  513. {
  514. return _zoom;
  515. }
  516. /**
  517. * @private
  518. */
  519. public function set zoom(Zoom:Number):void
  520. {
  521. if(Zoom == 0)
  522. _zoom = defaultZoom;
  523. else
  524. _zoom = Zoom;
  525. setScale(_zoom,_zoom);
  526. }
  527. /**
  528. * The alpha value of this camera display (a Number between 0.0 and 1.0).
  529. */
  530. public function get alpha():Number
  531. {
  532. return _flashBitmap.alpha;
  533. }
  534. /**
  535. * @private
  536. */
  537. public function set alpha(Alpha:Number):void
  538. {
  539. _flashBitmap.alpha = Alpha;
  540. }
  541. /**
  542. * The angle of the camera display (in degrees).
  543. * Currently yields weird display results,
  544. * since cameras aren't nested in an extra display object yet.
  545. */
  546. public function get angle():Number
  547. {
  548. return _flashSprite.rotation;
  549. }
  550. /**
  551. * @private
  552. */
  553. public function set angle(Angle:Number):void
  554. {
  555. _flashSprite.rotation = Angle;
  556. }
  557. /**
  558. * The color tint of the camera display.
  559. */
  560. public function get color():uint
  561. {
  562. return _color;
  563. }
  564. /**
  565. * @private
  566. */
  567. public function set color(Color:uint):void
  568. {
  569. _color = Color;
  570. var colorTransform:ColorTransform = _flashBitmap.transform.colorTransform;
  571. colorTransform.redMultiplier = (_color>>16)*0.00392;
  572. colorTransform.greenMultiplier = (_color>>8&0xff)*0.00392;
  573. colorTransform.blueMultiplier = (_color&0xff)*0.00392;
  574. _flashBitmap.transform.colorTransform = colorTransform;
  575. }
  576. /**
  577. * Whether the camera display is smooth and filtered, or chunky and pixelated.
  578. * Default behavior is chunky-style.
  579. */
  580. public function get antialiasing():Boolean
  581. {
  582. return _flashBitmap.smoothing;
  583. }
  584. /**
  585. * @private
  586. */
  587. public function set antialiasing(Antialiasing:Boolean):void
  588. {
  589. _flashBitmap.smoothing = Antialiasing;
  590. }
  591. /**
  592. * The scale of the camera object, irrespective of zoom.
  593. * Currently yields weird display results,
  594. * since cameras aren't nested in an extra display object yet.
  595. */
  596. public function getScale():FlxPoint
  597. {
  598. return _point.make(_flashSprite.scaleX,_flashSprite.scaleY);
  599. }
  600. /**
  601. * @private
  602. */
  603. public function setScale(X:Number,Y:Number):void
  604. {
  605. _flashSprite.scaleX = X;
  606. _flashSprite.scaleY = Y;
  607. }
  608. /**
  609. * Fetches a reference to the Flash <code>Sprite</code> object
  610. * that contains the camera display in the Flash display list.
  611. * Uses include 3D projection, advanced display list modification, and more.
  612. * NOTE: We don't recommend modifying this directly unless you are
  613. * fairly experienced. For simple changes to the camera display,
  614. * like scaling, rotation, and color tinting, we recommend
  615. * using the existing <code>FlxCamera</code> variables.
  616. *
  617. * @return A Flash <code>Sprite</code> object containing the camera display.
  618. */
  619. public function getContainerSprite():Sprite
  620. {
  621. return _flashSprite;
  622. }
  623. /**
  624. * Fill the camera with the specified color.
  625. *
  626. * @param Color The color to fill with in 0xAARRGGBB hex format.
  627. * @param BlendAlpha Whether to blend the alpha value or just wipe the previous contents. Default is true.
  628. */
  629. public function fill(Color:uint,BlendAlpha:Boolean=true):void
  630. {
  631. _fill.fillRect(_flashRect,Color);
  632. buffer.copyPixels(_fill,_flashRect,_flashPoint,null,null,BlendAlpha);
  633. }
  634. /**
  635. * Internal helper function, handles the actual drawing of all the special effects.
  636. */
  637. internal function drawFX():void
  638. {
  639. var alphaComponent:Number;
  640. //Draw the "flash" special effect onto the buffer
  641. if(_fxFlashAlpha > 0.0)
  642. {
  643. alphaComponent = _fxFlashColor>>24;
  644. fill((uint(((alphaComponent <= 0)?0xff:alphaComponent)*_fxFlashAlpha)<<24)+(_fxFlashColor&0x00ffffff));
  645. }
  646. //Draw the "fade" special effect onto the buffer
  647. if(_fxFadeAlpha > 0.0)
  648. {
  649. alphaComponent = _fxFadeColor>>24;
  650. fill((uint(((alphaComponent <= 0)?0xff:alphaComponent)*_fxFadeAlpha)<<24)+(_fxFadeColor&0x00ffffff));
  651. }
  652. if((_fxShakeOffset.x != 0) || (_fxShakeOffset.y != 0))
  653. {
  654. _flashSprite.x = x + _flashOffsetX + _fxShakeOffset.x;
  655. _flashSprite.y = y + _flashOffsetY + _fxShakeOffset.y;
  656. }
  657. }
  658. }
  659. }