rossi46 Posted June 29, 2017 Share Posted June 29, 2017 I use pixi timer plugin. it works on pixi 3.0.8 but not work on 4.5.1. How to fixed and build it. Link: https://github.com/Nazariglez/pixi-timer Or how to use eventemitter as timer Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 29, 2017 Share Posted June 29, 2017 Actually, according to the source code, it has to work with 4.5.3 . Just use "PIXI.tickers.shared" or "app.ticker" (if you have application like in pixi-examples), add the timer handler there. Quote Link to comment Share on other sites More sharing options...
rossi46 Posted June 29, 2017 Author Share Posted June 29, 2017 2 hours ago, ivan.popelyshev said: Actually, according to the source code, it has to work with 4.5.3 . Just use "PIXI.tickers.shared" or "app.ticker" (if you have application like in pixi-examples), add the timer handler there. i've just tried pixi 4.5.3. it didn't work. i say "Cannot read property 'update' of undefined", but when i use pixi 3.0.8, it works. I use file pixi-timer.js in plugin. I use many timer in game. ticker can replace for setTimeout?? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 29, 2017 Share Posted June 29, 2017 Give me a snippet of your code, how did you register the handler. Quote Link to comment Share on other sites More sharing options...
rossi46 Posted June 30, 2017 Author Share Posted June 30, 2017 4 hours ago, ivan.popelyshev said: Give me a snippet of your code, how did you register the handler. I use original example of pixi-timer. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Pixi.js Test</title> <script src="https://pixijs.download/v4.5.3/pixi.min.js"></script> <script src="js/pixi-timer.js"></script> </head> <body> <script> var renderer = new PIXI.autoDetectRenderer(800,600); document.body.appendChild(renderer.view); var stage = new PIXI.Container(); function animate(){ window.requestAnimationFrame(animate); renderer.render(stage); PIXI.timerManager.update(); } animate(); var timer = PIXI.timerManager.createTimer(1000); timer.repeat = 15; timer.on('start', function(elapsed){console.log('start')}); timer.on('end', function(elapsed){console.log('end', elapsed)}); timer.on('repeat', function(elapsed, repeat){console.log('repeat', repeat)}); //timer.on('update', function(elapsed, delta){console.log('update',elapsed, delta)}); timer.on('stop', function(elapsed){console.log('stop')}); </script> </body> </html> it doesn't run. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 30, 2017 Share Posted June 30, 2017 Never use ".min.js" unless you are ready for production. OK found this line: https://github.com/Nazariglez/pixi-timer/blob/master/src/Timer.js#L1 The project built with browserify and somehow it doesnt see PIXI. I dont know what to do in that case, its JS problem. You have to clone it and debug what's wrong, or may be remove all "import/export". The least - you can build it without minification, and find the line in compiled js file that isnt working. I'm sorry, that author chose ES6 with browserify. It has side effects. Quote Link to comment Share on other sites More sharing options...
Taz Posted June 30, 2017 Share Posted June 30, 2017 On 6/30/2017 at 5:36 AM, ivan.popelyshev said: OK found this line: https://github.com/Nazariglez/pixi-timer/blob/master/src/Timer.js#L1 The project built with browserify and somehow it doesnt see PIXI. import PIXI from 'pixi.js'; Maybe try putting local copy of newest pixi.js in same source folder and see if you can rebuild pixi-timer.js? I'm not familiar enough to know how to build/bundle it with Browserify thou. Maybe better luck to open GitHub issue and ask its dev how to build for new Pixi release. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 30, 2017 Share Posted June 30, 2017 Its compile-time import, so I dont know how exactly do they import it. Quote Link to comment Share on other sites More sharing options...
tywang2006 Posted July 4, 2017 Share Posted July 4, 2017 import PIXI from 'pixi.min.js' Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 4, 2017 Share Posted July 4, 2017 I'm not sure it will help. But anyway, I recommend to not use minifies AT ALL. Quote Link to comment Share on other sites More sharing options...
xerver Posted July 4, 2017 Share Posted July 4, 2017 import * as PIXI from 'pixi.js'; See: https://github.com/pixijs/pixi.js/issues/3500#issuecomment-269174274 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.