Mehrdad Posted September 6, 2017 Share Posted September 6, 2017 Hi everyone, I'm new to pixi.js, I have made sprite and moving it by followcurve function, I want to detect mouse collision with sprite and change followcurve path, but I can't stop sprite and starting new path until the sprite reach to the end of current path. xDestinition = yDestinition = 0; function play() { if (pointer.hitTestSprite(cat)) { console.log('*****************************************'); gotoNewPath(cat); } z = Math.floor(giveMeDistance(cat.x, cat.y, xDestinition, yDestinition)); if (z == 0) { gotoNewPath(cat); } } function gotoNewPath(movingObj, xD, yD, time) { xDestinition = (xD != null) ? xD : giveMeRand(fWidth); yDestinition = (yD != null) ? yD : giveMeRand(fHeight); let curve = [ [movingObj.x, movingObj.y], [giveMeRand(fWidth), giveMeRand(fHeight)], [giveMeRand(fWidth), giveMeRand(fHeight)], [xDestinition, yDestinition] ]; c.followCurve( movingObj, curve, 120, "smoothstep", false ); } Any advice? thanks. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 6, 2017 Share Posted September 6, 2017 followCurve is not the part of pixi 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.