shohan4556

Members
  • Content Count

    118
  • Joined

  • Last visited

Posts posted by shohan4556


  1. I think your code is ok, your state is changed, every state by default has a black background color. try to print which state it after clicking

    console.log(game.state.getCurrentState()); // it will print the current state.


  2. Hi, I have create a simple tilemap using tiled editor the map has just single layer but when I tried to collide my player with tilemap then this wired problem happened.

    Sometimes my player collide correctly sometime it overlapping. pic more more details understanding.

    here is the minimal code 

    for full project https://github.com/shohan4556/Cowboy-Shooter/tree/master/script

    MyGame.playState.prototype = {
    
        create: function () {
            console.log(game.state.getCurrentState());
            this.game.physics.startSystem(Phaser.Physics.ARCADE);
          
            this.map = this.game.add.tilemap('tilemap');
            this.map.addTilesetImage('sheet','tileset'); 
            // create the layer 
            this.layer = this.map.createLayer(0); 
            this.layer.resizeWorld();
            
            this.map.setCollisionBetween(0, 133);
    
        },
    
        update: function () {
            this.game.physics.arcade.collide(this.player, this.layer);
    
        },

    the first image is overlapping and the second image is colliding with the tile. it happens randomly when I move my player around.

    p1.PNG

    p2.PNG


  3. On 4/12/2016 at 7:52 PM, VitaZheltyakov said:

    Use code:

    
    this.game.scale.fullScreenScaleMode = Phaser.ScaleManager.SHOW_ALL;
    this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
    this.game.scale.refresh();
    
    canvas_width = window.innerWidth * window.devicePixelRatio;
    canvas_height = window.innerHeight * window.devicePixelRatio;
    aspect_ratio = canvas_width / canvas_height;
    if (aspect_ratio > 1) scale_ratio = canvas_height / canvas_height_max;
    else scale_ratio = canvas_width / canvas_width_max;
    
    this.ball = game.add.sprite((game.world.centerX), game.world.centerY, 'ball');
    this.ball.scale.set(scale_ratio);

    what will be the canvas_height_max and canvas_width_max size ? 


  4. 2 hours ago, VitaZheltyakov said:

    Use code:

    
    this.game.scale.fullScreenScaleMode = Phaser.ScaleManager.SHOW_ALL;
    this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
    this.game.scale.refresh();
    
    canvas_width = window.innerWidth * window.devicePixelRatio;
    canvas_height = window.innerHeight * window.devicePixelRatio;
    aspect_ratio = canvas_width / canvas_height;
    if (aspect_ratio > 1) scale_ratio = canvas_height / canvas_height_max;
    else scale_ratio = canvas_width / canvas_width_max;
    
    this.ball = game.add.sprite((game.world.centerX), game.world.centerY, 'ball');
    this.ball.scale.set(scale_ratio);

     

    I tried your code but I dont know why its not working.

    The scaling method you showed here I had used my project before it just scale game objects but the position problem is still happening.