Laumark 0 Report post Posted March 4, 2016 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 Quote Share this post Link to post Share on other sites
ivan.popelyshev 1072 Report post Posted March 4, 2016 Which browser are you using? Lambda-functions are supported in Chrome. Quote Share this post Link to post Share on other sites
mattstyles 667 Report post Posted March 4, 2016 Firefox and Edge also have support for arrows Quote Share this post Link to post Share on other sites
Laumark 0 Report post Posted March 4, 2016 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? Quote Share this post Link to post Share on other sites
mattstyles 667 Report post Posted March 4, 2016 You'll need a compile step to change that ES2015 code into stuff that all browsers understand. My recommendation would be babel, and do it as a build step, not at runtime. Quote Share this post Link to post Share on other sites
Laumark 0 Report post Posted March 4, 2016 Ok, thanks! But isn't there an easier way to handle clicking elements? Quote Share this post Link to post Share on other sites
mattstyles 667 Report post Posted March 4, 2016 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 1 Laumark reacted to this Quote Share this post Link to post Share on other sites
fire7side 7 Report post Posted March 4, 2016 I just tried it using buttonMode = true and the hand appears when I run it so apparently it can be set interactive same as a sprite. Quote Share this post Link to post Share on other sites
d13 105 Report post Posted March 5, 2016 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 1 Laumark reacted to this Quote Share this post Link to post Share on other sites
Laumark 0 Report post Posted March 7, 2016 Ah, amazing! Just what I was looking for Thanks! Quote Share this post Link to post Share on other sites