greg500 Posted November 27, 2017 Share Posted November 27, 2017 Hey, I have some problems with drawing the animation using pixi-tween. I want to animate a drawing of a stroke along the bezier path. I am basis on this example -> https://github.com/Nazariglez/pixi-tween/blob/master/examples/easing.html but my code still doesn’t work. Any idea where am I wrong? That's the code: var app = new PIXI.Application(1200, 800, {antialias: true}); document.body.appendChild(app.view); var raf; function animate(){ raf = window.requestAnimationFrame(animate); app.render(app.stage); PIXI.tweenManager.update(); } function stop(){ window.cancelAnimationFrame(raf); } var path = new PIXI.tween.TweenPath(); path.moveTo(0.4,0.4); path.bezierCurveTo(0.4,360.5,292.29,652.4,652.4,652.4); path.bezierCurveTo(87.5,65.4,105.9,47,105.9,24.89); path.closed = true; var t = new PIXI.Graphics(); app.stage.addChild(t); var tween = PIXI.tweenManager.createTween(t); tween.on('update', function(delta){ tween.path = path; tween.time = 13000; tween.easing = PIXI.tween.Easing.outBounce(); tween.loop = true; tween.lineStyle(10, 0xff0000); tween.drawPath(path); tween.start(); }); animate(); ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
bubamara Posted November 28, 2017 Share Posted November 28, 2017 you see no animation, right? you have to call animate(); first or use app's ticker instead ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
greg500 Posted November 28, 2017 Author Share Posted November 28, 2017 Yes, I called animate() and made some modifications but the stroke isn't animate along the Bezier curve. This is a code: var app = new PIXI.Application(1200, 800, {antialias: true}); document.body.appendChild(app.view); var path = new PIXI.tween.TweenPath(); path.moveTo(0.4, 0.4); path.bezierCurveTo(0.4, 360,292, 652, 652, 652); path.bezierCurveTo(87, 65, 105, 47, 105, 24); path.closed = true; var t = new PIXI.Graphics(); app.stage.addChild(t); // t.lineStyle(10, 0xff0000); // t.drawPath(path); var tween = PIXI.tweenManager.createTween(t); tween.path = path; tween.time = 13000; tween.easing = PIXI.tween.Easing.outBounce(); tween.loop = true; tween.on('start', function() { t.lineStyle(10, 0xff0000); t.drawPath(path); }); tween.start(); app.ticker.add(function(delta){ PIXI.tweenManager.update(); }); Do you have any idea what should be correct? Quote Link to comment Share on other sites More sharing options...
greg500 Posted December 23, 2017 Author Share Posted December 23, 2017 I've back to this project again. Any idea where am I wrong? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 24, 2017 Share Posted December 24, 2017 code looks good. Make a fiddle, people here are very lazy, nobody wants to create html file, download pixi and tweens e.t.c. Quote Link to comment Share on other sites More sharing options...
greg500 Posted December 27, 2017 Author Share Posted December 27, 2017 The stroke does not draw but the whole object is move according to the path (unexpected). https://jsfiddle.net/kuguar/f5qvkfq0/5/ Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 28, 2017 Share Posted December 28, 2017 You have to clear the whole graphics and refill it every frame, or add more lines to the end of it. Anyway, whatever you pass to PIXI.Graphics cant be edited later, only removed completely, if you want to know why, please look in the source code or try to replicate same thing with pure webgl. Quote Link to comment Share on other sites More sharing options...
greg500 Posted December 28, 2017 Author Share Posted December 28, 2017 Thank you. I understand the idea of how to animate the stroke in pure pixi.js but I wonder if there is an easy way to do this using pixi-tween. I want to use pixi-tween because it's easier to control visual aspects of my project and put quickly some design corrections (for example the speed of drawing the stroke) Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 28, 2017 Share Posted December 28, 2017 According to docs and sources, pixi-tween does not have this feature. Even more, I dont know any plugins that animate Graphics properly except https://github.com/jiborobot/pixi-animate , Adobe Animate exporter. It would be good to make one. 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.