freuxdesbois Posted October 26, 2016 Share Posted October 26, 2016 Hello there, First, I have to say I really love this tool, so easy and fast, you rock guys ! (if they come here, dunno) So, I'm trying to make a drag n drop application with the last version of pixi and I started with the example from the website (http://pixijs.github.io/examples/#/demos/dragging.js), Then I tried to compile the code to make an exe via nwjs (nw -r mypath) , but the touch/click events don't seem to work. everything is fine on firefox, chrome & IE don't work I tried to run this on my wamp server, and that works great everywhere. So It seems the problem lies in crossdomain policies ? if so, is there a workaround ? here is the code, for now : var renderer = PIXI.autoDetectRenderer(800, 600); document.body.appendChild(renderer.view); // create the root of the scene graph var stage = new PIXI.Container(); // create a texture from an image path var texture = PIXI.Texture.fromImage('bunny.png'); for (var i = 0; i < 10; i++) { createBunny(Math.floor(Math.random() * 800) , Math.floor(Math.random() * 600)); } function createBunny(x, y) { // create our little bunny friend.. var bunny = new PIXI.Sprite(texture); // enable the bunny to be interactive... this will allow it to respond to mouse and touch events bunny.interactive = true; // this button mode will mean the hand cursor appears when you roll over the bunny with your mouse bunny.buttonMode = true; // center the bunny's anchor point bunny.anchor.set(0.5); // make it a bit bigger, so it's easier to grab bunny.scale.set(3); // setup events bunny // events for drag start .on('mousedown', onDragStart) .on('touchstart', onDragStart) // events for drag end .on('mouseup', onDragEnd) .on('mouseupoutside', onDragEnd) .on('touchend', onDragEnd) .on('touchendoutside', onDragEnd) // events for drag move .on('mousemove', onDragMove) .on('touchmove', onDragMove); // move the sprite to its designated position bunny.position.x = x; bunny.position.y = y; // add it to the stage stage.addChild(bunny); } requestAnimationFrame( animate ); function animate() { requestAnimationFrame(animate); // render the stage renderer.render(stage); } function onDragStart(event) { // store a reference to the data // the reason for this is because of multitouch // we want to track the movement of this particular touch this.data = event.data; this.alpha = 0.5; this.dragging = true; } function onDragEnd() { this.alpha = 1; this.dragging = false; // set the interaction data to null this.data = null; } function onDragMove() { if (this.dragging) { var newPosition = this.data.getLocalPosition(this.parent); this.position.x = newPosition.x; this.position.y = newPosition.y; } } Quote Link to comment Share on other sites More sharing options...
freuxdesbois Posted October 27, 2016 Author Share Posted October 27, 2016 Still haven't found out, but the strange thing is older pixi versions like 2.2.9 are working (I'll try to gradually downgrade the versions to check the difference in the event manager) Quote Link to comment Share on other sites More sharing options...
xerver Posted October 28, 2016 Share Posted October 28, 2016 10 hours ago, freuxdesbois said: Still haven't found out, but the strange thing is older pixi versions like 2.2.9 are working (I'll try to gradually downgrade the versions to check the difference in the event manager) If you familiar with git bisect, tracking down the sha would be useful. Quote Link to comment Share on other sites More sharing options...
freuxdesbois Posted October 29, 2016 Author Share Posted October 29, 2016 On 28/10/2016 at 9:13 AM, xerver said: If you familiar with git bisect, tracking down the sha would be useful. I'm not familiar with bisect, but I'll give it a try since I really want to use PIXI as an exe file (seems faster than phaser) 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.