Jump to content

Flip of figure


JcKairos
 Share

Recommended Posts

I am currently creating a program to teach players about symmetry but I encountered some problem

This is what I want to get:

whatiwant.gif.a98443fcb272c3046047f429fbb3d6b1.gif

The program works fine when flipping horizontally.

However when it comes to diagonal:

notwhatiwant.gif.753ce77c650ff1ade5da816696856d92.gif

Is it possible for the figure to flip diagonally while it stays on the line of symmetry and not not fly out of it?

Flip code of horizontal:

this.game.add.tween(graphicsend.scale).to( { x: graphicsend.scale.x*-1}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { x: 450}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { alpha: 0.5 }, 500, Phaser.Easing.Linear.None, true);
     this.game.time.events.add(Phaser.Timer.SECOND * 1, function () {
        this.tweenTint(graphicsend, 0xffffff, 0x6666ff, 500);
        this.game.add.tween(graphicsend.scale).to( { x: graphicsend.scale.x*-1}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { x: 0}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { alpha: 1 }, 500, Phaser.Easing.Linear.None, true);
    }, this);
     this.game.time.events.add(Phaser.Timer.SECOND * 2.5, function () {
        this.tweenTint(graphicsend, 0x6666ff, 0xffffff, 500);
    this.game.add.tween(graphicsend.scale).to( { x: graphicsend.scale.x*-1}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { x: 450}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { alpha: 0.5 }, 500, Phaser.Easing.Linear.None, true);
}, this);
     this.game.time.events.add(Phaser.Timer.SECOND * 3.5, function () {
        this.tweenTint(graphicsend, 0xffffff, 0x6666ff, 500);
        this.game.add.tween(graphicsend.scale).to( { x: graphicsend.scale.x*-1}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { x: 0}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { alpha: 1 }, 500, Phaser.Easing.Linear.None, true);
}, this);

 

Flip code for diagonal:

this.game.add.tween(graphicsend.scale).to( { x: graphicsend.scale.x*-1}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { x: 318}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { y: 408}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { alpha: 0.5 }, 500, Phaser.Easing.Linear.None, true);
     this.game.add.tween(graphicsend).to({angle:'+90'}, 500, Phaser.Easing.Linear.None, true);

    this.game.time.events.add(Phaser.Timer.SECOND * 1, function () {
        this.tweenTint(graphicsend, 0xffffff, 0x6666ff, 500);
        this.game.add.tween(graphicsend.scale).to( { x: graphicsend.scale.x*-1}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { x: 133}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { y: 220}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { alpha: 1 }, 500, Phaser.Easing.Linear.None, true);
     this.game.add.tween(graphicsend).to({angle:'-90'}, 500, Phaser.Easing.Linear.None, true);
    }, this);
     this.game.time.events.add(Phaser.Timer.SECOND * 2.5, function () {
        this.tweenTint(graphicsend, 0x6666ff, 0xffffff, 500);
     this.game.add.tween(graphicsend.scale).to( { x: graphicsend.scale.x*-1}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { x: 318}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { y: 408}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { alpha: 0.5 }, 500, Phaser.Easing.Linear.None, true);
     this.game.add.tween(graphicsend).to({angle:'+90'}, 500, Phaser.Easing.Linear.None, true);
}, this);
     this.game.time.events.add(Phaser.Timer.SECOND * 3.5, function () {
        this.tweenTint(graphicsend, 0xffffff, 0x6666ff, 500);
       this.game.add.tween(graphicsend.scale).to( { x: graphicsend.scale.x*-1}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { x: 133}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { y: 220}, 500, Phaser.Easing.Linear.None, true);
    this.game.add.tween(graphicsend).to( { alpha: 1 }, 500, Phaser.Easing.Linear.None, true);
     this.game.add.tween(graphicsend).to({angle:'-90'}, 500, Phaser.Easing.Linear.None, true);
}, this);

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...