forleafe Posted December 2, 2016 Share Posted December 2, 2016 I feel embarrassed, but after doing a lot of research I can't seem to be able to implement this simple feature. Can anyone here who's familiar with pixi walk me through how I might accomplish this? Things I've tried... I'm trying to use .on('click', move) and then I have the move function right now set to just return the value of the pointer. I can't even get my code to return anything, let alone move the sprite. I've tried doing stage.on('click', move); and it just doesn't work. I get no errors in the console. nothing. It just doesn't work. After that, I tried creating a rectangle and using rectangle.on('click', move); I even fill in the rectangle with a color to make sure it's actually there. Nothing. my code is just unresponsive. No errors no nothing. The only time my code works is when I use the .on('click', move) on the actual sprite I'm trying to move! sprite.on('click', move). It will then return 'undefined' indicating that I at least got that far... I can provide my code if needed. But first I wanted to just check in and see what the best practice is for this, and if I'm just missing something elementary. Quote Link to comment Share on other sites More sharing options...
babycarlitos Posted December 2, 2016 Share Posted December 2, 2016 Hello forleafe, That does sound "simple". I suggest copying the code in the example and trying it out to see what it is that you are doing wrong. http://pixijs.github.io/examples/#/demos/dragging.js Hopefully that link helps you out. Quote Link to comment Share on other sites More sharing options...
forleafe Posted December 5, 2016 Author Share Posted December 5, 2016 That's not the feature I want. I've already implemented what you linked just fine. I needed click and move, not dragging. Quote Link to comment Share on other sites More sharing options...
babycarlitos Posted December 7, 2016 Share Posted December 7, 2016 I have no idea why I thought that you wanted drag. I just made this check it out to see if it is what you need https://jsfiddle.net/babycarlitos/9nLLc7je/32/ Quote Link to comment Share on other sites More sharing options...
cnwerb Posted December 7, 2016 Share Posted December 7, 2016 29 minutes ago, babycarlitos said: I have no idea why I thought that you wanted drag. I just made this check it out to see if it is what you need https://jsfiddle.net/babycarlitos/9nLLc7je/32/ Hi babycarlitos, I was also looking for a similar function, I want to make my pixi stage interactive, so it will respond to click events such as right click and similar. I'm just looking at your code to try and see how you've done it. From what I can see, you've created an invisible background component/element/sprite which responds to the click events, and then moves the red box to the point where the mouse was clicked. Am correct to say this is what you've done? Quote Link to comment Share on other sites More sharing options...
babycarlitos Posted December 8, 2016 Share Posted December 8, 2016 Hello cnwerb, Yes that is pretty much what I did. I made a blackish sprite that is the size of the window and added events to it. You can take the code and expand on it to add more events. In my case my "stage" is a container and making the stage interactive has a different behavior. Adding a sprite seems much easier. 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.