Laumark

tink.js strange function

Recommended Posts

Hey, I need help from somebody who know tink.js.

I'm making a small game in pixi.js where I'm also using the tink.js library.

In their introduction they are telling me to use this function to do something on click:

anySprite.press = () => {
  //Do something when the pointer presses the sprite
};

But it just sends me an error in the console. The structure looks weird to me.. Can this be the right way to use it?

I have a text, where I want something to happen when it is clicked, so I used

t.makeInteractive(varD);

And then in the play function

varD.press = () => {
   console.log("pressed");
};

But it just returns [Error] SyntaxError: Unexpected token ')'

What am I doing wrong?

Also, is there an easier way to do something on click? Perhaps just using pixi.js without tink.js?

Hope someone can help

Share this post


Link to post
Share on other sites

Yeah, I'm in Safari.. It works fine in Chrome. But I need it to run on Safari on my phone as well, so is there a way I can make it do that?

Also, can i check if a text element is clicked with just the pixi.js library?

Share this post


Link to post
Share on other sites

I havent used Pixi in a while but I thought you could make any object 'interactable'. There have been some changes to the interaction manager stuff though. I never really did it as I liked Pixi for rendering and not the other stuff it exposes.

Someone else will know though, you'll get an answer :) 

Share this post


Link to post
Share on other sites

Hi.. I'm the tink.js author!

Sorry for the trouble you're having, that JS code is written in ES6.

Here's the ES3/4 version:

varD.press = function(){
   console.log("pressed");
};

That should work :)

 

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.

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

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.