rich

Administrators
  • Content Count

    6,458
  • Joined

  • Last visited

  • Days Won

    298

Reputation Activity

  1. Like
    rich got a reaction from Tilde in Add bitmapdata to cache as image   
    Because makeParticles only accepts a string key (or array of keys). Here is how to use a bmd with an emitter:
    // Here is our custom ParticleMonsterParticle = function (game, x, y) { Phaser.Particle.call(this, game, x, y, game.cache.getBitmapData('particleShade'));};MonsterParticle.prototype = Object.create(Phaser.Particle.prototype);MonsterParticle.prototype.constructor = MonsterParticle;var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create, render: render });function create() { game.stage.backgroundColor = '#003663'; // Create our bitmapData which we'll use as our particle texture var bmd = game.add.bitmapData(64, 64); var radgrad = bmd.ctx.createRadialGradient(32, 32, 4, 32, 32, 32); radgrad.addColorStop(0, 'rgba(1, 159, 98, 1)'); radgrad.addColorStop(1, 'rgba(1, 159, 98, 0)'); bmd.context.fillStyle = radgrad; bmd.context.fillRect(0, 0, 64, 64); // Put the bitmapData into the cache game.cache.addBitmapData('particleShade', bmd); // Create our emitter emitter = game.add.emitter(game.world.centerX, 200, 200); emitter.width = 800; // Here is the important line. This will tell the Emitter to emit our custom MonsterParticle class instead of a normal Particle object. emitter.particleClass = MonsterParticle; emitter.makeParticles(); emitter.minParticleSpeed.set(0, 300); emitter.maxParticleSpeed.set(0, 400); emitter.setRotation(0, 0); emitter.setScale(0.1, 1, 0.1, 1, 12000, Phaser.Easing.Quintic.Out); emitter.gravity = -200; emitter.start(false, 5000, 100); game.input.onDown.add(updateBitmapDataTexture, this);}function updateBitmapDataTexture() { // Get the bitmapData from the cache. This returns a reference to the original object var bmd = game.cache.getBitmapData('particleShade'); bmd.context.clearRect(0, 0, 64, 64); // createRadialGradient parameters: x, y, innerRadius, x, y, outerRadius var radgrad = bmd.ctx.createRadialGradient(32, 32, 4, 32, 32, 32); var c1 = Phaser.Color.getWebRGB(Phaser.Color.getRandomColor(0, 255, 255)); var c2 = Phaser.Color.getWebRGB(Phaser.Color.getRandomColor(0, 255, 0)); radgrad.addColorStop(0, c1); radgrad.addColorStop(1, c2); bmd.context.fillStyle = radgrad; bmd.context.fillRect(0, 0, 64, 64); // All particles using this texture will update at the next render bmd.dirty = true;}function render() { game.debug.text('Click to regenerate the texture', 16, 28);}
  2. Like
    rich got a reaction from Tilde in Add bitmapdata to cache as image   
    game.cache.addBitmapData(key, bmd); But you don't use the key when adding a Sprite, otherwise it will think you've given it an Image key. Instead do this:
    game.add.sprite(x, y, game.cache.getBitmapData(key));
  3. Like
    rich got a reaction from Tilde in Create/cache spritesheet from generated texture   
    Here you go - this is how to do it from a Texture:
    http://phaser.io/examples/v2/display/spritesheet-from-graphics
  4. Like
    rich got a reaction from mattstyles in How do you time a pointerdown event?   
    In 3.15:
    this.input.on('pointerup', function (pointer) { var duration = pointer.upTime - pointer.downTime; }); In 3.16:
    this.input.on('pointerup', function (pointer) { var duration = pointer.getDuration(); });  
  5. Like
    rich got a reaction from Pavel Mishin in Get image from cache   
    As has been mentioned, all images are stored in the Texture Manager. You can get the raw image data like this:
    var tex = this.textures.get('key'); tex.getSourceImage(); You can pass getSourceImage a frame key, should the texture span multiple image files (like in a multi-texture set-up)
  6. Thanks
    rich got a reaction from jake.caron in Passing an image from one scene to the next.   
    A RenderTexture would work if you save it to the Texture Manager (via saveTexture), but a CanvasTexture might be a lot easier as they're automatically saved to the Texture Manager, so are globally accessible by default.
  7. Like
    rich got a reaction from Mattia in Welcome to the Facebook Instant Games forum   
    Hi all,
    I've created this sub-forum specifically for discussion about Facebook Instant Games. Use it to chat about the API, ask questions and post links to tutorials or code you've found useful.
    It doesn't matter what HTML5 game framework you're using (if any), but if you are using one, please say so in your post, so others can better help you. The FB API is the same regardless, but how you implement it is likely framework specific.
    This forum will be moderated by Facebook Instant Games staff where possible.
    Cheers,
    Rich
  8. Like
    rich got a reaction from willis in Wrong picked object by id (custom poperties). Phaser 3 bugs or my code mistake?   
    The two bits of code do completely different things. Hinted pieces array clearly doesn’t hold the array indexes, but rather the id values. Game Objects in Phaser don’t have an id property, so this is something you added.
  9. Like
    rich got a reaction from Wingnut in New forum   
    It's fine, I just need to check all tables for an IP address column and blank them if they have them, plus erase the users table (you still have the usernames of those who made the posts in the actual posts table). Then you can do whatever you want with the actual data.
    I can provide a dump of attachments too, but only once, as it's time-consuming. So let me know when you want me to do that. It will be up to you to consolidate these files with the attachment IDs in the database. I'm not sure how much space you get with Discourse, I think it's 1TB, before Deltakosh will have to start paying monthly to be hosted there.
    Just to clarify - forum updates are paid for until April 2019, after which it will still work, but Invision won't be updated any longer. Without BJS or Phaser here traffic will be really small, so I can move it to a cheap VPS and keep it online indefinitely (or until some massive Invision security flaw comes out!)
  10. Thanks
    rich got a reaction from Vousk-prod. in New forum   
    I'll provide a zip of all attachments when you request it, you can decide if you want to do anything with them or not after that.
  11. Thanks
    rich got a reaction from Vousk-prod. in New forum   
    I'll provide a zip of all attachments when you request it, you can decide if you want to do anything with them or not after that.
  12. Thanks
    rich got a reaction from Vousk-prod. in New forum   
    I'll provide a zip of all attachments when you request it, you can decide if you want to do anything with them or not after that.
  13. Thanks
    rich got a reaction from NasimiAsl in New forum   
    No-one has ever, ever, asked me for a copy of the forum database. So this is most certainly not a 'long time known issue'.
    You can have a copy of the MySQL db if you like. I just can't (and won't) include the users table, so it's useless for migrating to another host, but fine for extracting posts from.
  14. Thanks
    rich got a reaction from NasimiAsl in New forum   
    No-one has ever, ever, asked me for a copy of the forum database. So this is most certainly not a 'long time known issue'.
    You can have a copy of the MySQL db if you like. I just can't (and won't) include the users table, so it's useless for migrating to another host, but fine for extracting posts from.
  15. Thanks
    rich got a reaction from lemmikens in setInteractive() on a whole group   
    You could do:
    this.input.setHitArea(group.getChildren()); To figure out which sprite was clicked there are several ways of doing it. Either the 'gameobjectdown' events, or listen on the sprite itself. There's a tutorial about exactly this here: https://madmimi.com/p/a022cb
  16. Like
    rich got a reaction from Kaoff in Can't add rectangle ?   
    This is a known bug in 3.15.1, already fixed in 3.16 beta in the master branch. You don't have to add an image, you could also put a stroke on the rectangle (with alpha zero) and it'll work too.
  17. Like
    rich got a reaction from durandaimen1997 in Bullets not shooting properly   
    Like this (click Edit to see the code)
    http://labs.phaser.io/view.html?src=src/pools/bullets.js&v=dev
  18. Like
    rich got a reaction from thosakwe in Custom Builds?   
    For anyone else coming to this, there is now a proper tutorial on how to do this. You can find it here.
  19. Thanks
    rich got a reaction from DiegoMontania in Problem with transparency in tilemap   
    Fixed the tileset image - the problem is the tiles contain white instead of transparent pixels, so edit them in an art package.
  20. Like
    rich got a reaction from kurhlaa in Disabling lights makes objects invisible   
    You need to set all of the objects using the Light2D pipeline back to the TextureTintPipeline.
  21. Like
    rich got a reaction from rex in Ctrl key + arrow down together: How do I check for this?   
    this.input.keyboard.on('keydown_A', function (event) { if (event.ctrlKey) { console.log('A + CTRL'); } else if (event.altKey) { console.log('A + ALT'); } else if (event.shiftKey) { console.log('A + Shift'); } else { console.log('A without modifier'); } });  
  22. Like
    rich got a reaction from rex in Ctrl key + arrow down together: How do I check for this?   
    this.input.keyboard.on('keydown_A', function (event) { if (event.ctrlKey) { console.log('A + CTRL'); } else if (event.altKey) { console.log('A + ALT'); } else if (event.shiftKey) { console.log('A + Shift'); } else { console.log('A without modifier'); } });  
  23. Like
    rich got a reaction from OneSillyLion in What would you recomend to replace Signals?   
    One day I really ought to write an article about what's good for a web app is almost never good for a game loop.
  24. Thanks
    rich got a reaction from webdva in How do I stop the game from pausing when player switches tabs?   
    You can't do it, and Phaser 2 can't do it either. It's entirely up to the browser if it thinks the tab is no longer active (i.e. switching away), so it will slow down, and then stop, any running scripts relying on setTimeout or raf, which in effect pauses your game. Phaser 3 actually never pauses automatically (aside from audio, the main loop never stops).
    The solution is to capture when it happens and recover gracefully from it (just like you'd need to in v2, or any other framework)
  25. Like
    rich got a reaction from webdva in New to Phaser. Have questions.   
    1) Not really. Use the v3 API docs and examples.
    2) Yes, there’s a great tutorial on doing this on Game Dev Academy
    3) Not without using an app like Electron to package it for local use.
    4) Take your pick! I use both MAMP Pro and http-server
    5) Use whatever you like. ES6 would be fine!