Jump to content

OOP and Tweens


0penS0urce
 Share

Recommended Posts

I am trying to create an object class, and then make it follow a tween in order to follow a path in a Tower Defense game. However. I get an error: Undefined TypeError : undefined is not a function on the Phaser 2.3 JS file on line 1454. If there is a way to get the object to follow the path, like with physics, please include it and an example. Thanks in Advance! ;)

var demoTween;enemy = function(x, y, game){    Phaser.Sprite.call(this, game, x, y, 'enemy');    game.add.tween(this).to({x:800,y:600},5000);}enemy.prototype = Object.create(Phaser.Sprite.prototype);enemy.prototype.constructor = enemy;var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update });function preload(){    game.load.image('enemy', 'assets/player.png');}function create() {    var en = enemy(0, 0, game);    game.add.existing(en);    }function update(){}
Link to comment
Share on other sites

I don't think you should use tweens for characters movements. Tweens are used for animations. Instead you should implement the behaviour of your "enemy" in its update function (check its coords and make him move accordingly).

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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