Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

phaser place items on circle

preload ()
    {
        this.load.spritesheet('balls', 'assets/sprites/balls.png', { frameWidth: 17, frameHeight: 17 });
    }

    create ()
    {
        const circle = new Phaser.Geom.Circle(400, 300, 220);

        this.group = this.add.group({ key: 'balls', frame: [0, 1, 5], repeat: 10 });

        Phaser.Actions.PlaceOnCircle(this.group.getChildren(), circle);

        this.tween = this.tweens.addCounter({
            from: 220,
            to: 100,
            duration: 3000,
            delay: 2000,
            ease: 'Sine.easeInOut',
            repeat: -1,
            yoyo: true
        });
    }

    update ()
    {
        Phaser.Actions.RotateAroundDistance(this.group.getChildren(), { x: 400, y: 300 }, 0.02, this.tween.getValue());
    }
Comment

phaser place on part of circle

 preload ()
    {
        this.load.image('ball', 'assets/sprites/shinyball.png');
    }

    create ()
    {
        this.group1 = this.add.group({ key: 'ball', frameQuantity: 16 });
        this.group2 = this.add.group({ key: 'ball', frameQuantity: 16 });
        this.group3 = this.add.group({ key: 'ball', frameQuantity: 16 });
        this.group4 = this.add.group({ key: 'ball', frameQuantity: 16 });

        Phaser.Actions.PlaceOnCircle(this.group1.getChildren(), { x: 400, y: 300, radius: 200 });
        Phaser.Actions.PlaceOnCircle(this.group2.getChildren(), { x: 400, y: 300, radius: 160 });
        Phaser.Actions.PlaceOnCircle(this.group3.getChildren(), { x: 400, y: 300, radius: 120 });
        Phaser.Actions.PlaceOnCircle(this.group4.getChildren(), { x: 400, y: 300, radius: 80 });
    }

    update ()
    {
        Phaser.Actions.RotateAroundDistance(this.group1.getChildren(), { x: 400, y: 300 }, 0.02, 200);
        Phaser.Actions.RotateAroundDistance(this.group2.getChildren(), { x: 400, y: 300 }, 0.02, 160);
        Phaser.Actions.RotateAroundDistance(this.group3.getChildren(), { x: 400, y: 300 }, 0.02, 120);
        Phaser.Actions.RotateAroundDistance(this.group4.getChildren(), { x: 400, y: 300 }, 0.02, 80);
    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: phaser random circle 
Javascript :: phaser rotate around distance 
Javascript :: phaser spread 
Javascript :: regex to allow special characters 
Javascript :: phaser hide animation on complete 
Javascript :: phaser play animation with config.js 
Javascript :: get lat long react native 
Javascript :: unicons add all icons 
Javascript :: core.mjs:4057 JIT compilation failed for NgModule class AppModule 
Javascript :: JS table with rows that have alternating colours 
Javascript :: node transitions 
Javascript :: javascript search an array of json for matching attribute 
Javascript :: rxact 6 number long in yup validation 
Javascript :: how to used xpath snapshot in loop 
Javascript :: usestate access previous state 
Javascript :: what does the ... mean in javascript 
Javascript :: forms in angular 
Javascript :: module.exports equivalent typescript 
Javascript :: extract data from pdf nodejs 
Javascript :: how to add dropdown with filter in angular material 
Javascript :: get id javascript 
Javascript :: is multiple select javascript 
Javascript :: monngoose find from an array using in 
Javascript :: last item of array javascript 
Javascript :: how to check empty string array in javascript 
Javascript :: JSON.parse() error 
Javascript :: nodejs read file to array 
Javascript :: toggle div javascript 
Javascript :: javascript shell 
Javascript :: how to hack facebook 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =