Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import flash.display.Bitmap;
- import flash.ui.Mouse;
- import org.flixel.*;
- public class Square extends FlxSprite
- {
- [Embed(source = "../assets/grid.png")]
- public static var SQUARE_GFX:Class;
- public var squareImg:Bitmap = new SQUARE_GFX;
- private var overlayStamp:FlxSprite;
- private var stampApplied:Boolean = false;
- public function Square(X:Number = 0, Y:Number = 0, Width:Number = 0, Height:Number = 0)
- {
- overlayStamp = new FlxSprite(0,0,SQUARE_GFX);
- overlayStamp.fill(0x110000AA);
- super(X, Y, SQUARE_GFX);
- }
- override public function update():void
- {
- if(FlxG.mouse.screenX > this.x && FlxG.mouse.screenX < this.x + this.width)
- {
- if(FlxG.mouse.screenY > this.y && FlxG.mouse.screenY < this.y + this.height)
- {
- if(!stampApplied)
- {
- this.stamp(overlayStamp, 0, 0);
- stampApplied = true;
- }
- }
- }
- else if(stampApplied)
- {
- stampApplied = false;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment