MonseuirComede Posted June 17, 2019 Share Posted June 17, 2019 Quote var anim_array = []; this.animations[animation_name].forEach(function(img_path) { anim_array.push(PIXI.Texture.fromImage(animation_name + "/" + img_path)); }); var new_head = new PIXI.extras.AnimatedSprite(anim_array); new_head.setTransform(old_head.x + 50, old_head.y + 50); new_head.onLoop = function() { console.log("LOOPING"); new_head.stop(); }; new_head.loop = true; new_head.animationSpeed = .1; new_head.play(); app.stage.addChild(new_head); Code above (within a function called animate_head). Won't log "LOOPING" or stop, but the animation displays on canvas and loops infinitely. Have been looking through forums and have no clue. The stop() call is just so I know the onLoop is working. With or without that line, still doesn't log. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 17, 2019 Share Posted June 17, 2019 > Have been looking through forums and have no clue. Welcome to open-source. AnimatedSprite is very easy class that is supposed to be overriden by dev, usually its functions are not enough. Place breakpoint there and debug whatever is wrong: https://github.com/pixijs/pixi.js/blob/dev/packages/sprite-animated/src/AnimatedSprite.js#L273 What version of pixijs do you use? Quote Link to comment Share on other sites More sharing options...
MonseuirComede Posted June 17, 2019 Author Share Posted June 17, 2019 Thank you very much for the reply! I went to make the breakpoint and it turns out I was using a script tag in the client towards an old version of pixi on Cloudflare before the addition of onLoop. I am updating the script tag to a static route towards the correct file in node_modules (per https://stackoverflow.com/questions/27464168/how-to-include-scripts-located-inside-the-node-modules-folder). I am indeed rather new to open source and had some skittishness about digging into libraries. I'll abolish that effect - for the future, when overriding a Pixi class, do you modify the js file directly or some other method? Thank you again. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 18, 2019 Share Posted June 18, 2019 > I am indeed rather new to open source and had some skittishness about digging into libraries. I'll abolish that effect - for the future, when overriding a Pixi class, do you modify the js file directly or some other method? PixiJS is focused on source-code , we have very good selection process for PR's and dont allow strange things that most people cant understand into it. you can extend class (override), you can patch it like "PIXI.AnimatedSprite.prototype.xxx = function() ... " or you can build your own pixi fork. I know big project with modified pixijs file, it happens. MonseuirComede 1 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.