Guest User

Untitled

a guest
Sep 3rd, 2018
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.     import flash.display.Bitmap;
  4.     import flash.ui.Mouse;
  5.    
  6.     import org.flixel.*;
  7.    
  8.     public class Square extends FlxSprite
  9.     {
  10.         [Embed(source = "../assets/grid.png")]
  11.         public static var SQUARE_GFX:Class;
  12.        
  13.         public var squareImg:Bitmap = new SQUARE_GFX;
  14.         private var overlayStamp:FlxSprite;
  15.         private var stampApplied:Boolean = false;
  16.        
  17.         public function Square(X:Number = 0, Y:Number = 0, Width:Number = 0, Height:Number = 0)
  18.         {
  19.             overlayStamp = new FlxSprite(0,0,SQUARE_GFX);
  20.             overlayStamp.fill(0x110000AA);
  21.            
  22.             super(X, Y, SQUARE_GFX);
  23.         }
  24.        
  25.         override public function update():void
  26.         {
  27.             if(FlxG.mouse.screenX > this.x && FlxG.mouse.screenX < this.x + this.width)
  28.             {
  29.                 if(FlxG.mouse.screenY > this.y && FlxG.mouse.screenY < this.y + this.height)
  30.                 {                  
  31.                     if(!stampApplied)
  32.                     {
  33.                         this.stamp(overlayStamp, 0, 0);
  34.                         stampApplied = true;
  35.                     }
  36.                 }              
  37.             }
  38.             else if(stampApplied)
  39.             {
  40.                 stampApplied = false;
  41.             }
  42.         }
  43.     }
  44. }
Add Comment
Please, Sign In to add comment