charakter
This commit is contained in:
@@ -92,18 +92,14 @@ class Player {
|
||||
}
|
||||
|
||||
createSprite() {
|
||||
// NEW: Use player_dreadlocks sprite (isometric 2.5D)
|
||||
let texKey = 'player_dreadlocks';
|
||||
// KRVAVA ŽETEV: Use new protagonist sprite
|
||||
let texKey = 'player_protagonist';
|
||||
|
||||
// Fallback chain if new sprite not loaded
|
||||
// Fallback to generated sprite if not loaded
|
||||
if (!this.scene.textures.exists(texKey)) {
|
||||
texKey = this.scene.textures.exists('player_walk') ? 'player_walk' : 'player_sprite';
|
||||
if (!this.scene.textures.exists(texKey)) {
|
||||
texKey = 'player';
|
||||
if (!this.scene.textures.exists(texKey)) {
|
||||
TextureGenerator.createPlayerSprite(this.scene, texKey);
|
||||
}
|
||||
}
|
||||
console.warn('⚠️ player_protagonist sprite not found! Generating fallback...');
|
||||
TextureGenerator.createPlayerSprite(this.scene, 'player_fallback');
|
||||
texKey = 'player_fallback';
|
||||
}
|
||||
|
||||
// Kreira sprite
|
||||
@@ -113,15 +109,13 @@ class Player {
|
||||
screenPos.y + this.offsetY,
|
||||
texKey
|
||||
);
|
||||
this.sprite.setOrigin(0.5, 1);
|
||||
this.sprite.setOrigin(0.5, 0.8); // Changed from 1 to 0.8 to show legs
|
||||
|
||||
// Scale based on sprite type
|
||||
if (texKey === 'player_dreadlocks') {
|
||||
this.sprite.setScale(2.5); // MUCH larger for better visibility
|
||||
} else if (texKey === 'player_walk') {
|
||||
this.sprite.setScale(2.5); // Old animated sprite
|
||||
if (texKey === 'player_protagonist') {
|
||||
this.sprite.setScale(1.0); // Smaller protagonist sprite
|
||||
} else {
|
||||
this.sprite.setScale(1.2); // Old static sprite
|
||||
this.sprite.setScale(1.0); // Fallback sprite
|
||||
}
|
||||
|
||||
|
||||
@@ -343,10 +337,35 @@ class Player {
|
||||
this.lastDir = { x: dx, y: dy };
|
||||
this.sprite.setFlipX(!facingRight);
|
||||
|
||||
// Play walking animation (with safety check)
|
||||
if (this.sprite.anims) {
|
||||
try {
|
||||
if (this.scene.anims.exists('protagonist_walk') && !this.sprite.anims.isPlaying) {
|
||||
this.sprite.play('protagonist_walk');
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore animation errors
|
||||
}
|
||||
}
|
||||
|
||||
// Hand offset
|
||||
const handOffset = facingRight ? 10 : -10;
|
||||
this.handSprite.setX(this.sprite.x + handOffset);
|
||||
this.handSprite.setFlipX(!facingRight);
|
||||
} else {
|
||||
// Stop animation when idle (with safety check)
|
||||
if (this.sprite.anims) {
|
||||
try {
|
||||
if (this.sprite.anims.isPlaying) {
|
||||
this.sprite.stop();
|
||||
}
|
||||
if (this.scene.anims.exists('protagonist_idle')) {
|
||||
this.sprite.play('protagonist_idle');
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore animation errors
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Collision Check
|
||||
|
||||
@@ -136,21 +136,19 @@ class PreloadScene extends Phaser.Scene {
|
||||
});
|
||||
|
||||
// New Processed Animations (Standardized 64x64 strips)
|
||||
this.load.spritesheet('player_walk', 'assets/sprites/player_walk_strip.png', { frameWidth: 64, frameHeight: 64 });
|
||||
this.load.spritesheet('zombie_walk', 'assets/sprites/zombie_walk_strip.png', { frameWidth: 64, frameHeight: 64 });
|
||||
|
||||
// KRVAVA ŽETEV - New Player Sprite (Protagonist with dreadlocks)
|
||||
this.load.spritesheet('player_protagonist', 'assets/sprites/player_walk_animations.png', {
|
||||
frameWidth: 128, // Adjust based on actual sprite size
|
||||
frameHeight: 128
|
||||
});
|
||||
}
|
||||
|
||||
createAnimations() {
|
||||
if (this.anims.exists('player_walk_anim')) return;
|
||||
|
||||
// Old animations
|
||||
this.anims.create({
|
||||
key: 'player_walk_anim',
|
||||
frames: this.anims.generateFrameNumbers('player_walk', { start: 0, end: 5 }),
|
||||
frameRate: 12,
|
||||
repeat: -1
|
||||
});
|
||||
if (this.anims.exists('protagonist_walk')) return;
|
||||
|
||||
// Zombie animations
|
||||
this.anims.create({
|
||||
key: 'zombie_walk_anim',
|
||||
frames: this.anims.generateFrameNumbers('zombie_walk', { start: 0, end: 5 }),
|
||||
@@ -158,18 +156,25 @@ class PreloadScene extends Phaser.Scene {
|
||||
repeat: -1
|
||||
});
|
||||
|
||||
// NEW: Isometric character animations (6 frames)
|
||||
this.anims.create({
|
||||
key: 'player_dreadlocks_walk',
|
||||
frames: this.anims.generateFrameNumbers('player_dreadlocks', { start: 0, end: 5 }),
|
||||
key: 'zombie_worker_walk',
|
||||
frames: this.anims.generateFrameNumbers('zombie_worker', { start: 0, end: 5 }),
|
||||
frameRate: 8,
|
||||
repeat: -1
|
||||
});
|
||||
|
||||
// KRVAVA ŽETEV: Protagonist animations
|
||||
this.anims.create({
|
||||
key: 'protagonist_walk',
|
||||
frames: this.anims.generateFrameNumbers('player_protagonist', { start: 0, end: 7 }),
|
||||
frameRate: 10,
|
||||
repeat: -1
|
||||
});
|
||||
|
||||
this.anims.create({
|
||||
key: 'zombie_worker_walk',
|
||||
frames: this.anims.generateFrameNumbers('zombie_worker', { start: 0, end: 5 }),
|
||||
frameRate: 8,
|
||||
key: 'protagonist_idle',
|
||||
frames: this.anims.generateFrameNumbers('player_protagonist', { start: 8, end: 9 }),
|
||||
frameRate: 2,
|
||||
repeat: -1
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user