How to use the phaser.Easing function in phaser

To help you get started, we’ve selected a few phaser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liip / liip10yearsgame / src / states / Game.js View on Github external
showNotice(x, y, text, style) {
		// show notice
		let notice = this.game.add.text(x, y, text, style)

		// animate notice
		let noticeTween = this.game.add.tween(notice).to({alpha: 0, y: notice.y - 30}, 800, Phaser.Easing.Linear.None, true)
		noticeTween.onComplete.addOnce((notice) => {
			notice.destroy()
		})
	}
github pavermakov / phaser-match-two / src / states / MainMenu.js View on Github external
_insertUI() {
    const linear = Phaser.Easing.Linear.None;
    const back = Phaser.Easing.Back.Out;
    const cubic = Phaser.Easing.Cubic.InOut;

    // animate logo
    const revealLogo = this.add.tween(this.logo).from({ alpha: 0 }, 1000, linear, true, 300);
    const enlargeLogo = this.add.tween(this.logo.scale).from({ x: 0.01, y: 0.01 }, 1000, back, true, 300);
    const moveLogo = this.add.tween(this.logo).to({ y: this.CENTERY * 0.5 }, 700, cubic, false, 350);
    const revealPlay = this.add.tween(this.play).from({ alpha: 0 }, 1000, linear, true, 2000);
    const revealSound = this.add.tween(this.sound).from({ alpha: 0 }, 1000, linear, true, 1000);

    enlargeLogo.chain(moveLogo);
  }
github mattbgold / phaser-tbs / src / controllers / game / unit / controller.ts View on Github external
for(let i in path) {
			switch(path[i]) {
				case 'up':
					yPos.push(--yy);
					xPos.push(xx);
					tween.to({ isoY: (yy) * this._config.cellSize }, time, Phaser.Easing.Linear.None);
					break;
				case 'down':
					yPos.push(++yy);
					xPos.push(xx);
					tween.to({ isoY: (yy) * this._config.cellSize }, time, Phaser.Easing.Linear.None);
					break;
				case 'left':
					xPos.push(--xx);
					yPos.push(yy);
					tween.to({ isoX: (xx) * this._config.cellSize }, time, Phaser.Easing.Linear.None);
					break;
				case 'right':
					xPos.push(++xx);
					yPos.push(yy);
					tween.to({ isoX: (xx) * this._config.cellSize }, time, Phaser.Easing.Linear.None);
					break;
				default:
					console.error('Invalid path');
			}
		}

		let posIndex = 1;
		tween.onChildComplete.add((a,b) => {
			if(posIndex >= xPos.length) return;
			posIndex++;
			unit.setXPosition(xPos[posIndex]);
github giongto35 / gowog / client / src / sprites / Effect.js View on Github external
export function explode (game, layer, x, y) {
  var emitter = game.add.emitter(x, y, 200);
  emitter.makeParticles('explode_particle');
  emitter.gravity = 0;
  emitter.setScale(0.2, 0.1, 0.2, 0.1, 500, Phaser.Easing.Linear.None);
  emitter.setAlpha(0.7, 0.3, 500, Phaser.Easing.Linear.None, false);
  emitter.setXSpeed(-1000, 1000);
  emitter.setYSpeed(-1000, 1000);
  emitter.explode(400, 200);
  layer.add(emitter);

  game.time.events.add(200, function () { emitter.destroy(); }, this);
}
github brenopolanski / phaser-es6-starter / src / js / states / PreloaderState.js View on Github external
create() {
    const tween = this.add.tween(this.preloadBar).to(
      { alpha: 0 }, 1000, Phaser.Easing.Linear.None, true
    );

    tween.onComplete.add(this.startMainMenuState, this);
  }
github brenopolanski / phaser-es6-starter / src / js / states / MainMenuState.js View on Github external
create() {
    this.background = this.add.sprite(0, 0, 'menuBackground');
    this.background.alpha = 0;

    this.logo = this.add.sprite(this.world.centerX, -300, 'logo');
    this.logo.anchor.setTo(0.5, 0.5);

    this.add.tween(this.background).to(
      { alpha: 1 }, 2000, Phaser.Easing.Bounce.InOut, true
    );

    this.add.tween(this.logo).to(
      { y: 220 }, 2000, Phaser.Easing.Elastic.Out, true, 2000
    );

    this.input.onDown.addOnce(this.fadeOut, this);
  }
github stella-yc / forest-adventure / src / sprites / Tree.js View on Github external
constructor ({ game, x, y, key, frame }) {
    super(game, x, y, key, frame)

    this.anchor.setTo(0.5, 1)
    this.game.physics.arcade.enable(this)
    this.body.gravity.y = 300
    this.body.collideWorldBounds = true
    this.scale.setTo(0.1, 0.1)
    this.body.checkCollision.up = true
    game.add.tween(this.scale).to({x: 1, y: 1}, 50, Phaser.Easing.Back.Out, true, 1000)
  }
github kavun / flabbybox / src / main.js View on Github external
var flyIn = function (sprite) {
	sprite.flyingIn = sprite.game.add.tween(sprite).to({
			y: 250
		}, 1000, Phaser.Easing.Quadratic.Out, true);

	sprite.flyingIn.onComplete.add(giveGravity.bind(this, sprite));

	sprite.game.add.tween(sprite).to({
			x: 100,
			angle: 0
		}, 1000, Phaser.Easing.Quadratic.Out, true);
};
github mattbgold / phaser-tbs / src / services / map_builder / service.ts View on Github external
private _animateCell(cell: GridCell): void {
		if (cell instanceof WaterCell) {
			let waterAnimation = this._game.add.tween(cell.spr).to({isoZ: -5}, 800, Phaser.Easing.Sinusoidal.InOut, false, 0, 0, true).loop(true);
			setTimeout(() => waterAnimation.start(), Math.random() * 1000);
		}
	}
}
github frnsys / the_founder / app / states / Market.js View on Github external
notice(tile, msg, offset) {
    var offset = offset || 70,
        coord = this.market.board.coordinateForPosition(tile.position),
        text = this.game.add.text(
          coord.x - offset, coord.y, msg,
          {fill: '#ffffff', stroke: '#000000', strokeThickness: 2, font: 'bold 24pt Work Sans'}),
        tween;
    this.market.board.tileGroup.add(text);
    tween = this.game.add.tween(text).to({
      x: coord.x - offset,
      y: coord.y - 100,
      alpha: 0
    }, 4000, Phaser.Easing.Quadratic.Out, true);
    tween.onComplete.add(function() {
      text.destroy();
    });
    tween.start();
  }