swemaniac

Members
  • Content Count

    8
  • Joined

  • Last visited

Everything posted by swemaniac

  1. If I understand you correctly you want to create sprite based on a custom texture that you create in memory (i.e. bitmap data)? With your graphics object you can use the generateTexture() method to get a texture that you can initialize your sprite with. graphics = game.add.graphics(0, 0); graphics.beginFill(0xFF33ff); graphics.drawPolygon(polygonStructure); graphics.endFill(); sprite = game.add.sprite(400, 300, graphics.generateTexture()); graphics.destroy(); Another way of doing it is to create a BitmapData object instead of using graphics, draw on it, and then use that as your texture for the sprite (this code is from the example at http://phaser.io/examples/v2/sprites/sprite-from-bitmapdata): // create a new bitmap data object var bmd = game.add.bitmapData(128,128); // draw to the canvas context like normal bmd.ctx.beginPath(); bmd.ctx.rect(0,0,128,128); bmd.ctx.fillStyle = '#ff0000'; bmd.ctx.fill(); // use the bitmap data as the texture for the sprite var sprite = game.add.sprite(200, 200, bmd);
  2. That's really interesting, for whatever reason I never thought a group could have a filter, but why not indeed. Sounds like a good idea actually. I just need to pass the groups around and remember to add components there instead of to the stage..... Thanks for the input!
  3. Hi everyone, I'm doing some lightmapping and deferred lighting with a shader and a render texture on the whole screen to produce ambient light and illuminating with selected light sources. I apply the lightmap filter to the whole world like so: this.game.world.filters = [lightmap]; This makes everything affected by the lightmap including the UI texts and stuff (obviously, since they attach to the stage like everything else I guess). My question is simply, is there a separate layer or such that I can use for UI stuff to exclude those things from the filter? My solution for this right now I think would be: Render the UI component to a separate render texture Render the whole stage to a separate render texture Apply the lightmap filter to the render texture with the stage components in it Clear the stage and render both textures back to it Would that be a viable solution? Or would it be a significant performance hit, rendering the stage multiple times...
  4. Okay thanks guys; I am already using custom sprites with overridden update methods and I was using addChild because it made the most sense, so I'll update the children explicitly.
  5. Hello, I've been searching around for an explanation/answer for this but I can't find anything definitive so here goes. If I add a sprite as a child to another sprite via Sprite.addChild(), the child's update() method is never called. If I add the child sprite to a Group which has a Sprite set as parent, the child's update() method is also never called. I've seen hints about this being "expected behavior" and/or related to Pixi but is it really? And why? Thanks
  6. Ok thanks lewster. Yeah the concept of tweens seems very attractive at first but they don't really fit when you need to do more advanced stuff I noticed.
  7. Hi, First off thanks to Phaser. It's awesome. How do I tween a sprite's angle from say 180 degrees to 360 degrees in a clockwise direction? If i just do tween.to({ angle: 360}) the sprite will rotate counter clockwise. In Phaser angles that would be from 180 to -90. Obviously it's because the tween will go down from 180 to -90, but I want it to to go upwards and wrap around i.e. 180, -179, -178 etc. Make any sense? Thanks