lmfielding

Members
  • Content Count

    10
  • Joined

  • Last visited

Posts posted by lmfielding


  1. This is the relevant code:
     
     
            const bounds = MapData.mapApp.renderer;
            
            const crossHairTexture = MapData.pixiLoader.resources['/static/assets/map/map_crosshair.png'].texture;
            let sprite = new PIXI.Sprite(crossHairTexture);
            
            sprite.anchor.set(0.5);
            sprite.width = sprite.height = MapData.tileHeight / 2;
     
            sprite.x = bounds.width / 2;
            sprite.y = bounds.height / 2;

  2. I have spent quite a few weeks on a few problems without asking for assistance but I feel that it is going to take me much longer to work out on my own so I request your help. :) Thank you!

     

    I want to place a sprite in the middle of the screen (square rotated 45 degrees)

    I want to place sprites next to this sprite in the middle of the screen so that they are aligned with no gaps

    I want to check where there are missing tiles (in relation to the centre (initial) sprite

     

    Most of my problems seem to be caused by the dimensions of the sprites changing based on outside circumstances (flexbox etc or initial dimensions not set on a SSR, irrelevant really).

    I have achieved a lot of this in varying ways but it seems hacky.

    Once I set the initial sprite, I have to change the pivot and position before or after rotation (can't remember) which causes a lot of problems because a square's width is no longer the same once you rotate it 45deg...

    ------

    I feel that I need to cleanly set the rotated sprite (square) to the center of the screen, then add the rest of the sprites RELATIVE to this one, rather than from trying to calculate screenWidth, worldWidth, etc.

    Please help before I make a horrible mistake by switching to phaser!