PageRenderTime 44ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/org/flixel/FlxCamera.hx

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