Loading first sprite
authorDavid Négrier <d.negrier@thecodingmachine.com>
Sun, 5 Apr 2020 14:20:53 +0000 (16:20 +0200)
committerDavid Négrier <d.negrier@thecodingmachine.com>
Sun, 5 Apr 2020 14:20:53 +0000 (16:20 +0200)
front/dist/resources/characters/pipoya/Male 01-1.png [new file with mode: 0644]
front/src/GameScene.ts

diff --git a/front/dist/resources/characters/pipoya/Male 01-1.png b/front/dist/resources/characters/pipoya/Male 01-1.png
new file mode 100644 (file)
index 0000000..d4c12b2
Binary files /dev/null and b/front/dist/resources/characters/pipoya/Male 01-1.png differ
index 9a4324492a79320cb2b27bfcc9336dda2c21cc82..b87235743a5aeca9dcb6f03f6639a5ebee2c9c0f 100644 (file)
@@ -10,6 +10,10 @@ export class GameScene extends Phaser.Scene {
     preload(): void {
         this.load.image('tiles', 'maps/tiles.png');
         this.load.tilemapTiledJSON('map', 'maps/map2.json');
+        this.load.spritesheet('player',
+            'resources/characters/pipoya/Male 01-1.png',
+            { frameWidth: 32, frameHeight: 32 }
+        );
     }
 
     init(): void {
@@ -22,6 +26,41 @@ export class GameScene extends Phaser.Scene {
         let bottomLayer = mappy.createStaticLayer("Calque 1", [terrain], 0, 0);
         let topLayer = mappy.createStaticLayer("Calque 2", [terrain], 0, 0);
 
+        // Let's manage animations of the player
+        this.anims.create({
+            key: 'down',
+            frames: this.anims.generateFrameNumbers('player', { start: 0, end: 3 }),
+            frameRate: 10,
+            repeat: -1
+        });
+
+        this.anims.create({
+            key: 'left',
+            frames: this.anims.generateFrameNumbers('player', { start: 4, end: 8 }),
+            frameRate: 10,
+            repeat: -1
+        });
+
+        this.anims.create({
+            key: 'right',
+            frames: this.anims.generateFrameNumbers('player', { start: 9, end: 12 }),
+            frameRate: 10,
+            repeat: -1
+        });
+
+        this.anims.create({
+            key: 'up',
+            frames: this.anims.generateFrameNumbers('player', { start: 13, end: 16 }),
+            frameRate: 10,
+            repeat: -1
+        });
+
+        //let player = this.add.sprite(450, 450, 'player');
+        //player.anims.play('down');
+        //player.setBounce(0.2);
+        //player.setCollideWorldBounds(true);
+
+
     }
 
     private angle: number = 0;