Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// PLAYSTATE ////
- class PlayState extends FlxState
- {
- var _testPice: Pice;
- var _testPice2: Pice;
- var _testPice3: Pice;
- override public function create()
- {
- super.create();
- _testPice = new Pice(0, 0, 1);
- _testPice2 = new Pice(0, 1, 2);
- _testPice3 = new Pice(1, 0, 1);
- add(_board);
- add(_testPice3);
- add(_testPice2);
- add(_testPice);
- Reg.boardData.add(_testPice);
- Reg.boardData.add(_testPice2);
- Reg.boardData.add(_testPice3);
- }
- override public function update(elapsed:Float)
- {
- super.update(elapsed);
- }
- }
- //////// PICE Class ////
- class Pice extends FlxSpriteGroup
- {
- ////// THIS IS THE PROPERTY AND IS PUBLIC
- public var player: Int;
- // Elements of the full pice
- public var pice: FlxExtendedSprite;
- public function new(?X:Int = 0, ?Y:Int = 0, ?Player:Int = 1)
- {
- super(X, Y, 0);
- // Sets pice position on board
- super(X * Config.PICE_SIZE, Y * Config.PICE_SIZE);
- // Identifier, player and type of pice
- player = Player; ///////HERE ITs
- // Load sprite for the pice
- pice = new FlxExtendedSprite(0, 0);
- pice.loadGraphic('assets/images/pice__f.jpg', false, Config.PICE_SIZE, Config.PICE_SIZE);
- /// Colors the pice depending on the player
- if (player == 1) {
- pice.color = FlxColor.fromRGB(184, 111, 60, 0);
- } else if (player == 2) {
- pice.color = FlxColor.fromRGB(235, 202, 163, 0);
- }
- //Adds objets to the group
- add(pice);
- }
- //////// PiceMove Classs WHERE THE OVERLAP IS CHECKED ////
- class PiceMove extends FlxExtendedSprite
- {
- var pice:Pice;
- var isOverlaping:Bool;
- public function new(X:Float = 0, Y:Float = 0, Face: String, ParentPice: Pice)
- {
- super(X * Config.PICE_SIZE, Y * Config.PICE_SIZE);
- pice = ParentPice;
- loadGraphic(AssetPaths.move__png, false, Config.PICE_SIZE, Config.PICE_SIZE);
- }
- override public function update(elapsed:Float)
- {
- super.update(elapsed);
- isOverlaping = FlxG.overlap(this, Reg.boardData, onOverlap);
- }
- private function onOverlap(object1, object2:Pice) {
- FlxG.log.add(object1.pice.player);
- FlxG.log.add(object2.player);
- object2.kill();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement