Sign in to follow this  

This context matters

Recommended Posts

Good morning guys!

I've created a class to manage my sliders in Phaser 2.6.2 with Typescript.

I create an object slider like this in file a.ts:

let slider = new Slider(game, x, y, width, height, mycallback);

mycallback is like that:

export function mycallback(value: number): void
   usedvalue = value;

My slider class is like that:

export class Slider extends Phaser.Group
    protected value              : number;
            game                 : Phaser.Game,
            x                    : number,
            y                    : number,
            width                : number,
            height               : number,
            onClickCallback      : Function

            this.value = sender.width - sender.x;

Ok, now both this.onClickCallback(this.value); and sender.onClickCallback(this.value); return an error "onClickCallback is not a function".

The first console.log(this), the one inside the constructror, give me the right log writing Slider and all his values.

The second console.log(this) and console.log(sender), the ones in setParameter, return me game.

What is my error?

How can I resolve this?

Share this post

Link to post
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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.