Flixel: doesn't light tile up
Posted
by
Arno
on Game Development
See other posts from Game Development
or by Arno
Published on 2012-06-30T15:50:38Z
Indexed on
2012/06/30
21:26 UTC
Read the original article
Hit count: 268
i'm creating a game with flixel, and I want to have a effect when you mouse over a tile, I tried implementing it, and this is what it gives:
public class GameState extends FlxState
{
private var block:EmptyBlock;
public function GameState()
{
}
override public function create():void {
for (var i:Number = 0; i < 30; i++) {
block = new EmptyBlock(i, 20);
block.create();
}
}
override public function update():void {
block.update();
super.update();
}
}
}
GameState class
and here is the EmptyBlock class:
public class EmptyBlock
{
private var x:int;
private var y:int;
private var row:FlxRect
public function EmptyBlock(x:int, y:int )
{
this.x = x;
this.y = y;
}
public function create():void {
row = new FlxRect(x, y, 32, 32);
trace ("Created block at" + x + y);
}
public function update():void {
if (FlxG.mouse.screenX == row.x) {
if (FlxG.mouse.screenY == row.y) {
var outline:FlxSprite = new FlxSprite(row.x, row.y).makeGraphic(row.width, row.height, 0x002525);
}
}
}
}
}
© Game Development or respective owner