Atlas and random aztec cryp loading

This commit is contained in:
Mashy
2018-12-15 11:30:22 +10:00
parent ddc009f80e
commit 9087b9bebc
3 changed files with 455 additions and 5 deletions
+2 -2
View File
@@ -127,8 +127,8 @@ class CrypImage extends Phaser.GameObjects.Image {
} = crypAvatarText(team, iter);
// Cryp display
const avatar = team ? 'magmar' : 'alk';
super(scene, crypAvatarX, crypAvatarY, avatar);
// const avatar = team ? 'magmar' : 'alk';
super(scene, crypAvatarX, crypAvatarY, 'aztec', `sprite${Math.floor(Math.random() * 19) + 1}`);
this.setScale(0.5);
// Save position and cryp details
+9 -3
View File
@@ -9,6 +9,7 @@ const CombatHitBox = require('./combat.hitbox');
const renderResolutions = require('./combat.render.resolutions');
const aztecAtlas = require('../../assets/aztec.atlas.json');
class Combat extends Phaser.Scene {
constructor() {
@@ -18,8 +19,13 @@ class Combat extends Phaser.Scene {
preload() {
// Textures already loaded can do proper check in future when theres more textures
if (!(this.textures.getTextureKeys().length > 2)) {
this.textures.addBase64('alk', `data:image/png;base64,${new Buffer.from(fs.readFileSync('./assets/alakazam-f.png')).toString('base64')}`);
this.textures.addBase64('magmar', `data:image/png;base64,${new Buffer.from(fs.readFileSync('./assets/magmar.png')).toString('base64')}`);
const aztecImg = new Image();
aztecImg.src = `data:image/png;base64,${new Buffer.from(fs.readFileSync('./assets/aztec.clean.png')).toString('base64')}`;
aztecImg.onload = () => {
this.textures.addAtlas('aztec', aztecImg, aztecAtlas);
};
// this.textures.addBase64('alk', `data:image/png;base64,${new Buffer.from(fs.readFileSync('./assets/magmar.png')).toString('base64')}`);
// this.textures.addBase64('magmar', `data:image/png;base64,${new Buffer.from(fs.readFileSync('./assets/magmar.png')).toString('base64')}`);
this.load.image('proj', 'https://labs.phaser.io/assets/sprites/bullet.png');
this.load.image('blue', 'https://labs.phaser.io/assets/particles/blue.png');
this.load.image('green', 'https://labs.phaser.io/assets/particles/green.png');
@@ -45,7 +51,7 @@ class Combat extends Phaser.Scene {
return ws.sendGameState(game.id);
}
return false;
}, 2000);
}, 500);
return true;
}