what context to pass for function

Recommended Posts


I am really confused why I am getting errors with this code from the weapon plugin:

  create: function() {
    //load current level

    this.weapon =, 'explode');
    this.weapon.fireFrom.setTo(300,300, 1, 1);

    this.weapon.bulletKillType = Phaser.Weapon.KILL_CAMERA_BOUNDS;
    this.weapon.bulletGravity.y = -1000;

        .onDown.add(, this);

The error is:

phaser.js:100951 Uncaught TypeError: Cannot read property 'width' of undefined
    at (phaser.js:100951)

It seems to be an issue with the context, but I have tried this.weapon, this.state, all to no avail. Annoyingly if I run from the console it shoots fine.

If anyone can see what I'm doing wrong I'd be very grateful.

Thanks, Gordon

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.