Laumark Posted March 4, 2016 Share 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 Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 4, 2016 Share Posted March 4, 2016 Which browser are you using? Lambda-functions are supported in Chrome. Quote Link to comment Share on other sites More sharing options...
mattstyles Posted March 4, 2016 Share Posted March 4, 2016 Firefox and Edge also have support for arrows Quote Link to comment Share on other sites More sharing options...
Laumark Posted March 4, 2016 Author Share 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 Link to comment Share on other sites More sharing options...
mattstyles Posted March 4, 2016 Share 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 Link to comment Share on other sites More sharing options...
Laumark Posted March 4, 2016 Author Share Posted March 4, 2016 Ok, thanks! But isn't there an easier way to handle clicking elements? Quote Link to comment Share on other sites More sharing options...
mattstyles Posted March 4, 2016 Share 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 Laumark 1 Quote Link to comment Share on other sites More sharing options...
fire7side Posted March 4, 2016 Share 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 Link to comment Share on other sites More sharing options...
d13 Posted March 5, 2016 Share 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 Laumark 1 Quote Link to comment Share on other sites More sharing options...
Laumark Posted March 7, 2016 Author Share Posted March 7, 2016 Ah, amazing! Just what I was looking for Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.