Jump to content

OOP and Tweens


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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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