• Content Count

  • Joined

  • Last visited

Everything posted by microspace

  1. No, I don't need to calculate position every frame, only once he crosses tile boundary. Maybe you are right
  2. Sorry, I didnt notice that I removed reference tile, thats why error occured
  3. Is there a way to determine sprite position in terms of tiles, faster than in the example: update: function () { var cposx = Math.floor(player.x / TileSize); var cposy = Math.floor(player.y / TileSize); } I dont want to load too much calculations inside update function. Maybe there is asynchronous way to do this or maybe there is built-in function to od this.
  4. I create layer from Tiled with these commands: var map; var fog; var flour; ... map = this.game.add.tilemap('lesson51'); map.addTilesetImage('tileSheetWinter', 'gameTiles'); flour = map.createLayer('flour'); fog = map.createLayer('fog'); flour.resizeWorld(); ... Why `map.getTileAbove(fog, x, y);` gives error TypeError: Cannot read property 'data' of undefined but map.getTile(x, y, fog); return Tile object as expected?
  5. Hello! I want to reload map, but this time without destroying map object. Previously I was doing it this way: Create: map = TopDownGame.game.add.tilemap("mytilemap"); map.addTilesetImage('tileSheet', 'myTiles'); flour = map.createLayer('flour'); Destroy and recreate: map.destroy(); flour.destroy(); map = TopDownGame.game.add.tilemap("mytilemap"); map.addTilesetImage('tileSheet', 'myTiles'); flour = map.createLayer('flour'); But here I have to destroy map object too. Is there a way to do this without destroying map object? (I now that I can always use `putTileWorld`)
  6. After some thinking, I came to conclusion that I need to sort individual tiles to achieve this. I simply want to avoid this: The ice mountain consists of 4 tiles nad it was created in Tiled. So the simplest solution is to recreate all such objects (as mountains) using sprites?
  7. Hello! Is there a way to sort tile layer on the map same as it is done here https://phaser.io/examples/v2/groups/depth-sort I the exxample sorting is done on group elements. I want to achieve same result as in example, but I operate with tile layers.
  8. Thank you, @samme, this was really helpful!
  9. In my game, player moves automatically using tween, than it shoots a bullet also automatically. Camera is set to follow player, so during the tweening world view changes. This causes the bullet to fly from the player too early, as if weapon chases the player during tweening and can't run after it. Here is example video of the bug. On the video we can see that bullet flies over barrel. But it must hit the barrel nad it does hit it sometimes. So the question is, how to skip couple of game ticks before shooting, so that the weapon and the player settle down to one coordinate? Or is there something like "force update screen"?
  10. So I had to put group of immovable and impassable sprites as a barier for upper level. Not a beautiful solution, but will do.
  11. I've got a tilemap created in Tiled and there is a platform with ladder on the map. How to make player stop when it tries to move from platform to group layer? Also how to make player collide with tiles pointed by green arrow when player approaches then from left, bot not collide when player approaches from right. Simply, is there `checkCollision` property for a tile?
  12. You need to place div contained with an id attribute: https://stackoverflow.com/a/21053003/1402321
  13. Hello! Here you go: https://github.com/rusi/canvas-demos Nice project! I'll appreciate if you show us the results 🙂
  14. But still I can't set opacity on tile inside game loop. Only on level creation.
  15. You do something like var frame = 10; player = GAME.add.sprite(0, 0, 'cardsheet', frame); That you can change sprite with player.frame = 15;
  16. Thanks for pointing in right direction var tile = this.map.getTile(10, 9, this.flour); if (tile) { tile.alpha = 0.5; }
  17. Is there a way to set transparency of a single tile inside game loop? I'm building some sort of level constructor and I want to find a way to grey out tiles.
  18. @samme, can you please explain how to use these functions, that you listed? I tried to use game.stage.updateTransform(); after my reset function, but no result. After randomly changing the code I've found that when I disable `fresh` parameter, the glitch disappears. this.pegmanSprite.fresh = false; Who can explain why is this happening?
  19. This glitch which I described occurs only when camera follow player.
  20. I have a sprite `player`. If I do `player.x = 200`, `player.y = 300` in a function which fires on a button click, does the movement of sprite itself take any games ticks?
  21. Strange bug occures when I try to move sprite to initial position in game. I use this command: this.gamesprite.reset(lastSuccessfullPosition.x, lastSuccessfullPosition.y); For a moment sprite gets separate from body. At this moment body overlaps a wall and collision callback is called. For this reason every time I press reset button, sprite behaves as if it hit the wall.
  22. I do this: //bullets weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; weapon.bulletAngleOffset = 0; weapon.bulletSpeed = 400; weapon.fireAngle = Phaser.ANGLE_RIGHT; // shoot at right direcion by default weapon.trackSprite(player, 0, -9, false); //-65 выведено экспериментальным путём //weapon.addBulletAnimation("fly", [0, 1, 2, 3, 4, 5, 6, 7], 40, true); this code executes when bullet hits barrel: bulletHitBarrel: function(sprite, bullet) { var damage = 48; sprite.damage(damage); explosion.x = sprite.x; explosion.y = sprite.y - 30; explosion.visible = true; explosion.animations.play('EXPL'); bullet.kill(); }, I think that this is bug. Anyway I avoided it the other way (I set limit for health to not to drop below minimal level)
  23. I'm creating group of items (barrels). After killing some of items with weapon, I call items.callAll('revive');, but barrels are spawning in random position. Who came across with this problem? items = this.game.add.group(); items.enableBody = true; // inside for loop: var sprite = group.create(element.x, element.y, 'barrel');
  24. When I set this.map.setTileIndexCallback([...Array(500).keys()], this.hitWall, this, this.blockLayer); , this.map.setCollisionBetween(1, 2000, true, 'blockLayer'); is ignored by Phaser. Is it ok?