themoonrat

Members
  • Content Count

    232
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by themoonrat

  1. themoonrat

    Texture / Sprite Slow to add to stage

    And unrelated(ish) - I always recommend creating sprites using Sprite.fromFrame() if you expect them to be preloaded. fromFrame will only look in the texture cache, and report an error if it's not found fromImage which will try to load the image if it's not in the texture cache If I know I'm preloading assets, I'd rather get an error that it doesn't exist and work out why.
  2. themoonrat

    Texture / Sprite Slow to add to stage

    If you wanted to be super quick about it, you could just iterate through everything in PIXI.utils.BaseTextureCache and upload everything from there.
  3. themoonrat

    Ticker FPS

    With JavaScript in the browser, you have to take the attitude that every line of code delivered to a user can be changed by them. So, taking away the tickets speed existence wouldn't solve anything, as they could manipulate the time deltas coming in from requestAnimationFrame manually (which is all the speed variable does in a ticker. You need the server to authenticate everything that the client is sending to the server. Validation on when the client is sending data to the server; ranges for how many times a second for example....and validation on every bit of data send to the server. If the client code is set so that it takes a player 1 second to run 100 pixels to the right, the server needs to validate this; if a client was x pos -500 one moment then x pos 500 the next, you know something fishy is up!
  4. themoonrat

    Container vs ParticleContainer

    It inherits from Container, but overrides a few critical methods related to updating the transforms and for rendering, in both cases optimising them for particle usage. The quickest way sometimes to look at the code rather then going though github is to go via the docs: http://pixijs.download/dev/docs/particles_ParticleContainer.js.html
  5. themoonrat

    Not able to make sprite interaction to work

    Don't worry about it, we've all been there at some stage!
  6. themoonrat

    Not able to make sprite interaction to work

    It's because you have a div that sits over the top of the canvas 'game-over-overlay' This is blocking the canvas getting interaction events
  7. themoonrat

    Text object shows as black box for long strings

    First, personally, I wouldn't use window.devicePixelRatio as the resolution modifier. If the resolution of the game is 960x540, and you use a devicePixelRatio of 3, then you're rendering now at a resolution of 2880x1620, which is pretty insane. By all means increase the resolution based on if the device screen is higher, or the device is more powerful, but I wouldn't link it necessarily to window.devicePixelRatio, and test out the visual quality yourself if you can see a difference. Second: I don't like the code you've pasted which forces the resolution of the text to match the resolution of the renderer. I believe you should be able to override it; so I might do a PR to allow that behaviour. Right now though you can achieve what you want by overriding this behaviour. Add the following code before you create the PIXI renderer. Now any resolution you set after creating the text will be the resolution used for any future updates of text; Object.assign( PIXI.Text.prototype, { renderWebGL: function( renderer ) { this.updateText( true ); PIXI.Sprite.prototype.renderWebGL.call( this, renderer ); }, renderCanvas: function( renderer ) { this.updateText( true ); PIXI.Sprite.prototype._renderCanvas.call( this, renderer ); } } );
  8. themoonrat

    Touch and click events on mobile

    First of all, I always prefer the second syntax. sprite.on('click', callback) Second, you can use pointer events instead of having both mouse and touch events sprite.on('pointerdown', callback); Examples have all been updated recently, so might be with having another look through them. For example: https://pixijs.github.io/examples/#/basics/click.js And the docs show all of the available events you can listen to: http://pixijs.download/v4.3.4/docs/PIXI.interaction.InteractionManager.html#event:click
  9. themoonrat

    How to add a shadow?

    Someone has provided a drop shadow filter at the bottom of https://github.com/pixijs/pixi-filters/pull/9
  10. themoonrat

    Simple lines with Pixi.js

    After modifying the myLine.graphicsData Try doing myLine.dirty++
  11. themoonrat

    Interactivity on masked object

    I believe this PR may shed light on your issue; are you using beginFill or not with your mask? If not, it will not be interactive
  12. themoonrat

    Packing tool for SpriteSheets

    I like using https://www.codeandweb.com/texturepacker Use json output. Not free, but it's good!
  13. themoonrat

    Make movieclip from several atlases and play it whithout lags

    Use the prepare plugin to upload textures to the gpu before you play the animation
  14. Some filters were moved to: https://github.com/pixijs/pixi-filters Also, that one, for some reason got dropped, though there is a PR open to re-add it: https://github.com/pixijs/pixi-filters/pull/9 Ask on there for a progress update
  15. There is no correct way; as you've noted, there are options available to different circumstances. One that throws errors if the texture is not found is my personal preference. Since I'm not using the loader in my game, I therefore use PIXI.Texture.fromFrame.
  16. themoonrat

    Correct linking in Brackets editor.

    You only get the confirmation message you're looking for once you've created a renderer
  17. themoonrat

    Detect when view has been rendered?

    I believe some of your pause maybe due to uploading textures to the GPU for the first time. You may want give the prepare plugin a go http://pixijs.download/v4.3.4/docs/PIXI.BasePrepare.html renderer.plugins.prepare.upload(textureOrContainer); Upload all of your textures after loading has ended, but before you've hidden the loading screen.
  18. themoonrat

    Texture/BaseTexture.fromImage onLoaded

    http://pixijs.download/release/docs/PIXI.Texture.html According to the bottom of that, there is an event you can subscribe to called 'update' texture = Texture.fromImage( 'blah.svg' ); texture.on('update', () => { console.log('yay'} ); But is there any reason you can't use the built in loader to do this for you? http://pixijs.download/release/docs/PIXI.loaders.Loader.html
  19. themoonrat

    How much of a performance gain using powers of 2

    For mobile, I'm happy with 2048x2048. Most devices do support 4096x4096 now, but I found that some devices would stutter sometimes, when the texture was being uploaded to the gpu, and older iphones showed weird artifacts But you want as few texture swaps as you can, which rules out 1024x1024. So 2048x2048 was the sweet spot for my needs
  20. True There are two paths you can take here 1. adding and removing sprites onto the container. Advantage, the renderer is only iterating through an array of children it actually needs to render, which will be quicker. Disadvantage, addChild and removeChild are manipulating arrays, which can be slow and janky. 2. create a pool of sprites you can use up front, and reuse them by changing changing visibility. Advantage, no touching arrays; a visible on/off switch is very simple and speedy. Disadvantage, you could be iterating through tons of sprites every frame that aren't ever going to be rendered, which is a waste of time As xerver says, you will have to profile your game to see which works out best in your circumstances. My instinct is 2, just to avoid dealing with constant array resizing, but i may be wrong!. Please let us know what performed better... I'd love to know the answer!
  21. themoonrat

    Touch Events in Container Children

    I'd rather do the later where possible, but If you wanted to do the former, then on a click/touch event callback from the parent you get can interactionEvent. interactionEvent.data.global will give you a Point object with the global x and y co-ordinates of the click/touch. If the children are a sprite/graphic, you can use that to call their containsPoint function; if not, you'll have to create your own similar function.
  22. Is there a reason you couldn't just set yourSprite.visible = false; On the ones you don't want to render anymore? That would be preferable and stops rendering or calculating transforms on those sprites.