oldmanvegas

Members
  • Content Count

    6
  • Joined

  • Last visited

  1. I figured it out. I used map.searchTileIndex(TileIndexNum,false,randomTile, layerName); I generated the randomTile variable by counting up the number of new tiles added and grabbed a random number from that range - so the function looked for a single tile each time and checked around it and spread the "fire" as it grew. Works pretty well.
  2. I've managed to get it working bar one issue - the forEach creates a new tile at 0,0 after the first iteration and then the new tiles spawn from there as expected, but the initial "seed tile" the one which should be the start point is ignored. For a dummy run I've made a simple 10x10 grid - the seed tile is at position 8,8. However the loop creates a tile at 9,8 as I'd expected - then randomly adds one at 0,0 and then grows out from there instead. fired by a timer: map.forEach(this.checkSpread, this, 0, 0, 10, 10, blocks) then function is as follows (I know it could be optimised but I'm just seeing what happens for now) checkSpread: function(block){ if(block.index === 107){ map.setLayer(blocks); var xPos = block.x; var yPos = block.y; console.log(xPos + "|" + yPos) //select direction at random? var randomValue = this.game.rnd.integerInRange(1, 4); switch(randomValue){ case 1: if(yPos > 0){ var topTile = map.hasTile(xPos, yPos - 1,blocks); if(!topTile && yPos > 0){ console.log("NO block above - fill it") map.fill(107, xPos, yPos-1, 1, 1, blocks) } } break; case 2: if(yPos < 9){ var underTile = map.hasTile(xPos, yPos + 1,blocks); if(!underTile){ console.log("NO block below - fill it") map.fill(107, xPos, yPos+1, 1, 1, blocks) } } break; case 3: if(xPos > 0){ var leftTile = map.hasTile(xPos -1, yPos,blocks); if(!leftTile && xPos > 0){ console.log("NO block left - fill it") map.fill(107, xPos-1, yPos, 1, 1, blocks) } } break; case 4: if(xPos < 9){ var rightTile = map.hasTile(xPos +1, yPos,blocks); if(!rightTile){ console.log("NO block right - fill it") map.fill(107, xPos+1, yPos, 1, 1, blocks) } } break; } // if(xPos > 1 && yPos > 1) // map.fill(107, xPos, yPos, 2, 2, blocks) } },
  3. I'm currently working with tiles to create levels - so far so good - I've managed to make a demo car game with a maze, collisions with walls and mines all working as expected. I'd like to extend the functionality with a new tileLayer with one tile on it - let's say its a tile indicating fire - and on a timer I'm firing a function which looks at the neighbouring tiles around it, and if they're empty (hasTile()?) then fill them with a fire tile - this means the fire layer will expand over time but only into neighbouring tiles. I'm currently using forEach to cycle through the tiles and only consider the ones with the correct tile index. I've tried using the function map.getTileAbove as a proof of concept but so far I can't work out why the response I'm getting is error (undefined) . Has anyone tried anything like this? And if so any advice would be appreciated. What's the best and most optimal way to check through the tiles to see if they're empty and then replace the tile texture? Cheers
  4. oldmanvegas

    Text cropping

    It may not be the perfect solution - but you could add a mask to your text component. So draw your rectangle as before with the same x&y as your text then set - text.mask = cropRect;
  5. Looking through the API docs it looks like there is no support for right to left text - is there any way to add this functionality to a phaser game? I'm intending on making a multilingual game and this functionality would be imperative to ensure that arabic etc could be used as a language option. Any help / advice much appreciated! Cheers OMV
  6. I would like to see a book on optimisation, and a class based approach - I've been making a few games for about 8 months now in Phaser and each one gets better and more efficient than the last. I have recently been using a more OOP approach - creating classes for each of my main game elements, which is more comparable to previous AS3/C# projects I have worked - on It's still very trial and error though! I'm really grateful for the library of examples which are invaluable to discover new techniques and methods - but I must admit I struggle with the Learn documentation - as it tells you what classes / parameters are but gives no examples of how to implement them - which often leaves me stumped. Some areas I think would be really useful: State engine Restart game state (resetting variables / tweens / initialising states etc efficiently) Breaking game elements into classes (a bit like lessmilk's flappy bird example) Using tilemaps loading game data from json or xml - (rather than writing a massive create function) Pixel perfect collision detection Thanks for an awesome game engine btw - it's an excellent project and I'm trying to convert as many people to it as possible!