Quantcast
Channel: Pixi.js Latest Topics
Viewing all articles
Browse latest Browse all 3980

Stoping followcurve

$
0
0

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.


Viewing all articles
Browse latest Browse all 3980

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>