Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

change origin phaser

function preload ()
{
    this.load.image('card', 'assets/sprites/mana_card.png');
    this.load.atlas('atlas', 'assets/atlas/megaset-1.png', 'assets/atlas/megaset-1.json');
}

function create ()
{
    //  Graphics background with lines on

    var graphics = this.add.graphics();

    //  Change originX to 1 so sprites are right-aligned

    this.add.image(200, 200, 'atlas', 'mana_card').setOrigin(1, 0.5);
    this.add.image(200, 400, 'card').setOrigin(1, 0.5);

    //   By default the origin is set to 0.5 (the center of the image)

    this.add.image(400, 200, 'atlas', 'mana_card');
    this.add.image(400, 400, 'card');

    //  Change originX to 0 so sprites are left-aligned

    this.add.image(600, 200, 'atlas', 'mana_card').setOrigin(0, 0.5);
    this.add.image(600, 400, 'card').setOrigin(0, 0.5);

    //  Draw the alignment lines to our Graphics object

    graphics.lineStyle(2, 0x00ff00, 1);

    graphics.beginPath();

    graphics.moveTo(200, 0);
    graphics.lineTo(200, 600);

    graphics.moveTo(400, 0);
    graphics.lineTo(400, 600);

    graphics.moveTo(600, 0);
    graphics.lineTo(600, 600);

    graphics.strokePath();

    graphics.closePath();
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: change rotation phaser 
Javascript :: Javascripti functions accepting Flask parameters to display a PDF file with Adobe Embed API 
Javascript :: Json to npy file 
Javascript :: find minimum 
Javascript :: phaser place on rectangle shift 
Javascript :: phaser set x y 
Javascript :: phaser create animation on sprite 
Javascript :: phaser pause animation instances 
Javascript :: How to call the API when the search value changes 
Javascript :: generate random email account javascript 
Javascript :: remove text and keep div inside a div jquery 2 
Javascript :: js undici 
Javascript :: React "Nothing was returned from render Error" Solution 
Javascript :: function Tom(a, b) { return a + b; } 
Javascript :: change on id 
Javascript :: express-js 
Javascript :: what does the ... mean in javascript 
Javascript :: js includes case insensitive 
Javascript :: add to map javascript 
Javascript :: map method in javascript 
Javascript :: grid in js 
Javascript :: first name last name concatenate javascript with ternary operator 
Javascript :: change url without reloading the page 
Javascript :: filter properties from object javascript 
Javascript :: function with .map javascript 
Javascript :: js Destructuring in React 
Javascript :: js module pattern 
Javascript :: lottie npm 
Javascript :: javascript advanced concepts 
Javascript :: how to write a factorial function in javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =