• Content count

  • Joined

  • Last visited

About Viktoria

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I have resolved the issue. The problem was that while jumping on a platform imported from json, the collision worked and the player could jump on the platform. But then it doesnt recognised the platform as the floor and the property sprite.body.touching.down was set to false. I just added the function to the collision between player and platforms in wich I specified that sprite.body.touching.down should be equal to true. And it worked then😁😁😁😁 function collidePlatforms(player,layer){ this.player.body.touching.down = true; }
  2. Viktoria


    I had the same issue. I don't kno why but another syntax helped me just well: = this.make.tilemap({ key: 'map' }); this.tiles ='platformSmallLevel2', 'plat'); this.layer =, this.tiles, 0, 0); this.layer.setCollisionByProperty({ collide: true });
  3. I have implemented tilemap from json file made in Tiled. It works fine. All platforms are shown. But then one issue occurs: when player jumps on a platform it collides with it(ok), but then he cannot jump upwards. preload(){ this.load.json('level','src/scenes/levels.json'); this.load.image('ground','src/assets/plattformBigLevel2.png'); this.load.image('background','src/assets/backgroundLevel2_4000.png'); this.load.image('platform','src/assets/platformSmallLevel2.png'); this.load.tilemapTiledJSON('map', 'src/assets/tiled/Level2.json'); this.load.spritesheet('player','src/assets/bug.png',{ frameWidth: 55, frameHeight: 56 }); } create(){ //background this.image = this.add.image(2000,600,'background'); //create a big platform this.platforms = this.physics.add.staticGroup(); this.platforms.create(2000, 568,'ground'); //create platforms = this.make.tilemap({ key: 'map' }); this.tiles ='platformSmallLevel2', 'platform'); this.layer =, this.tiles, 0, 0); this.layer.setCollisionByProperty({ collide: true }); let player_config = { x: this.levelData.playerStart.x, y: this.levelData.playerStart.y, name: this.player_type, lives: this.player_lives, cursors: this.input.keyboard.createCursorKeys() } this.player = new Player(this, player_config); this.player.setCollideWorldBounds(true); this.physics.add.collider( this.player,this.platforms); this.physics.add.collider(this.player, this.layer); }
  4. Yes..but that was not a problem. Thank you for response. It turned out that an error was shown because despite the player was dead - an update() method called bug.move() method and as a result an error occured. in update() method it should be checked if a bug is alive. If yes then move() method should be called but if not then - do nothing.😊 update(){ if(this.bug.isAlive()){ this.bee.move(); this.bug.move(); } }
  5. I am writing a function for collider. In the function should be checked if the player is still alive. When yes then the live will be decreased and one "heart" symbol from the lives-pannel will be deleted(the player has 3 lives aka heart symbols). The function works perfectly till the place where the player has no lives. My idea was when the player has no more lives than the game should be stopped and the intro scene should be called. But every time no matter what I do I get an Error: class Level extends Phaser.Scene{ constructor(){ super({ key:"Level" }); } preload(){ this.load.spritesheet('kaefer','src/assets/bug.png',{ frameWidth: 55, frameHeight: 56 }); this.load.spritesheet('butterfly','src/assets/butterfly.png',{ frameWidth: 55, frameHeight: 56 }); this.load.image('heart','src/assets/heart.png'); this.load.json('level','src/scenes/levels.json'); this.load.image('arbeitsbiene','src/assets/arbeitsbiene.png'); } //take the data from Menu Level init(data){ this.player_type = data.player; } create(){ //configuration for player let player_config = { x: this.levelData.playerStart.x, y: this.levelData.playerStart.y, name: this.player_type, cursors: this.input.keyboard.createCursorKeys() } //create player this.bug = new Kaefer(this, player_config); this.bug.setCollideWorldBounds(true); this.physics.add.collider( this.bug,this.platforms); //create hearts bar this.lifes = this.physics.add.staticGroup(); for(let i = 0; i< this.bug.lives; i++){ let j = i + 1; this.lifes.create(35 * j, 20, 'heart'); } console.log(this.lifes); // let bee = { x: 350, y: 400, name: 'arbeitsbiene', //facing_left: false, speed: 150, jump: 340 } this.bee = new ArbeitsBiene(this, bee); this.physics.add.collider(this.bee,this.platforms); //this.physics.add.collider(this.bee, this.ground); this.bee.setCollideWorldBounds(true); this.physics.add.overlap(this.bee, this.bug, hitBee, null, this); function hitBee(bee,bug){ let heart = this.lifes.getChildren();// gets an array if children [entr0,entr1,entr2] let alive = this.bug.isAlive();//the method from bug Class. Checks if a bug is still alive if(alive){ heart[heart.length-1].destroy();//destroyes one heart symbol this.bug.setX(this.levelData.playerStart.x); this.bug.setY(this.levelData.playerStart.y-100); this.bug.lives = this.bug.lives - 1; }else{ this.scenee.start('Menu'); } } update(){ this.bug.move(); this.bee.move(); } }