jonteferm

Members
  • Content count

    18
  • Joined

  • Last visited

About jonteferm

  • Rank
    Member

Profile Information

  • Gender
    Male
  • Location
    Sweden

Recent Profile Visitors

214 profile views
  1. You can set the size of the sprite body - if that is what you are after. sprite.body.setSize(width, height, offsetX, offsetY) https://phaser.io/examples/v2/arcade-physics/offset-bounding-box
  2. Thanks! That works fine. Pretty obvious, but I did not think of it
  3. Hello, I have a problem with handling the collision between sprites. I have a group of enemies and a player sprite. I want none of the sprites to be able to move trough each others. At first I had the enemy body set to immovable and that disabled the player from pushing the enemy around upon collision. However, when I added more enemies to the group, I found that if the enemy bodies is set to immovable = true - they will be able to walk straight trough each others even if they have an internal collision detection (as that is the case between two immovable bodies). So if i set immovable to false - the enemies will appear solid when colliding with each other, but the player is able to push the enemy. What is it that I have not understood? I just want all the sprites solid.
  4. Hey! You can call this function on the tilemap: getTile(x, y, layer, nonNull). The X and Y should be given in tile units and not pixels, so for instance: if you have a 32x32 grid - tile unit 1 would be pixels 0-31 etc. You can see the full documentation here http://phaser.io/docs/2.4.4/Phaser.Tilemap.html#getTile.
  5. I don't know about the assets. I suppose it's free to use in your case but I let someone else answer that. But... Have you ever checked out this site? http://opengameart.org/ You might find some really cool stuff to use.
  6. Aah! Thank you Yes, that looks a bit weird in this context. It is a variable global to the game. I don't need to pass map to the function at this point - obviously as I do not even use it xD . But in the future - I thought maybe I will have more map objects representing levels and stuff which will load it's separate enemies. But now when I think of it: Why? I can't imagine I will ever have to view more than one map at once. Yes, you are right they should not be immovable. I guess I thought of "immovable" as "impassable". Also, when trying the line with the callback - I made the arcade.collide call in the wrong way. Thank you!
  7. Hey! I have a group of enemies created like this (called from create()): spawnEnemies: function(map){ this.enemies = this.game.add.group(); this.enemies.enableBody = true; this.game.physics.arcade.enable(this.enemies); var enemyStartPositions = this.findObjectsByType('enemyStart', this.map, 'objectLayer'); for(var i = 0; i < enemyStartPositions.length; i++){ var enemyStart = enemyStartPositions[i]; var enemy = new Enemy(this.game, enemyStart.x, enemyStart.y, 'cultist'); enemy.countStats(); this.enemies.add(enemy); } this.enemies.setAll("body.immovable", true); } In the update function - I try to detect the collision between the children in the group like in this example (using 2.4.7): http://examples.phaser.io/_site/view_full.html?d=arcade physics&f=group vs self.js&t=group vs self&phaser_version=v2.4.7& this.game.physics.arcade.collide(this.enemies); But they wont collide with - just passing trough - each other. Also tried with adding a callback as when I let the player sprite collide with the enemy group like this: this.game.physics.arcade.collide(this.player, this.enemies, this.collisionHandlerPlayerAndEnemy, null, this); this.game.physics.arcade.collide(this.enemies, null, this.collisionHandlerEnemyAndEnemy); And the callback-function will not be called (may it be that this does not even work at all when the case is group to group?). I need someone elses eyes on this. No properties for enemy body is set outside these code blocks.
  8. One suggestion would be to set up a web server and host it in a machine at home. Of course that may require you to buy something to host from if you don't want to keep your home computer running 24/7. I host from my Raspberry Pi 3 Of course that has some limitations depending on what will be on your website.
  9. Awsome! Yes, this works just as fine in this case. I use to create backgroundLayer and blockLayer in tiled and set collision on the whole block layer (because everything is just walls). Then I have an object layer for doors, items, npc starting positions and stuff that is going to be interacted with. Though, the tiles in the object layer are only placeholders to which I - in Tiled - assign properties with the name of the sprite/sprites that I should use in phaser as most of the stuff in my object layer use sprite-sheets for animation.
  10. If you want to get a specific tile out of a layer though. You can call this on the tilemap: getTile(x, y, layer, nonNull) . But that will be a tile object and not a sprite. Yes maybe the createFromObjects will work. Maybe iterating trough the tilemap and call that for every tile as it requires the layer array index.
  11. Ah, I see what you mean. If you should be able to call the sprite body in that way - the sprite must be it's own sprite object like the player Unit you got. So if I were you - I would create the towers in the object layer in tiled.
  12. About the collision: you can specify a custom bounding box by calling sprite.body.setSize(width, height, offsetX, offsetY).
  13. Looks like the walls is just a layer and not a group with enabled arcade physics. It will not work with the arcade.collide as it is just for stuff that have arcade physics. Have you tried to set collissionBetween to more than that? I have to set it to at least 3000 in my game for collision to take place.
  14. I'm using 4.7. Seems like it is the same params. But hey, I solved it. By just removing that damned else condition and adding this instead: this.events.onAnimationComplete.add(function(){ this.animations.stop(true, true); }, this); Thanks for looking into this!
  15. Okey, yes that is true. I thought of it in the wrong way. I guess my problem is that during the next frame, it enters the else - where the animation stops - as I am no longer holding down the button. So what i probably have to do; is to flag in some way that a animation is still in play and in that case prevent the animations.stop() even though it enters the else. However, I am under the impression that this is exactly what should be solved by the second parameter in my call to the animations.stop() function (dispatchComplete) which I set to true. Maybe I got that wrong.