Jump to content

TypeScript Mouse/Touch events scope


Recommended Posts

Hey all, I am using Alamboley's excellent TypeScript port :D


I am having a little trouble with scopes, it is more of a TypeScript help than pixi but wth!

In this example that I made up (pseudo). A function is bound to the bunny? Hence this(bunny).alpha = 0;
class Something{        constructor()       {            //....            // use the mousedown and touchstart            bunny.mousedown = bunny.touchstart = function(data)            {                // store a refference to the data                // The reason for this is because of multitouch                // we want to track the movement of this particular touch                this.data = data;                this.alpha = 0.9;                this.dragging = true;            };            //.....       }}

How would I bind this function to the Something class? 

class Something{     constructor()     {            //....            // use the mousedown and touchstart            bunny.mousedown = bunny.touchstart = ???            //.....      }      private onBunnyDown(data:PIXI.InteractionData): void      {              console.log("Hi");      }}


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...