• Content Count

  • Joined

  • Last visited

  1. nicoloko02

    Sprite.addChild(child) passes the child as a copy?

    Debugging I saw that they were really the same, but I didn't understand why when I was using "Phaser.debug.body" I saw the sprite rotating around the pivotSprite, and when I check for it's position it stayed in position (0, 100). So, in the update of my Bat class, that inherits from Sprite, I used this code: var point = this.follow.toGlobal(new Phaser.Point(0, 0));, point.x, point.y, this.moveSpeed); And that way worked as I wanted \o/ I looked at documentation, and now I understand why wasn't working before. The reason is that the Sprite.position is relative to the local coordinates of the parent, so I had to convert it using the Sprite.toGlobal. I started using Phaser recently and I'm really enjoing it, maybe soon I will have a little game to post here =-D Thanks for your help Rich. PS: sorry for my bad english x-D
  2. nicoloko02

    Group & Tilemap Collision & Issues

    Hello, maybe you are forgeting to set what tiles can be collidable. Take a look at some of these functions: Phaser.Tilemap.setCollisionByIndex(index, collides, layer, recalculate) : void; Phaser.Tilemap.setCollisionByExclusion(indexes, collides, layer, recalculate) : void; Phaser.Tilemap.setCollisionBetween(start, stop, collides, layer, recalculate) : void; Phaser.Tilemap.setCollision(indexes, collides, layer, recalculate) : void; I was with a problem like that, and it worked very well.
  3. nicoloko02

    Sprite.addChild(child) passes the child as a copy?

    Sorry, I changed the variable names just for better understanding and i forgot some of them o.รต Now it's right.
  4. Hello, I want to pass a Sprite that will rotate around a pivot sprite. So the child sprite will be added as a child using addChild. I want my bat to follow the childSprite, so I passed it to the follow variable. Example: this.pivotSprite = this.create(player.position.x, player.position.y + 100, 'invisible_block'); var childSprite = new Phaser.Sprite(, 0, this.pivotSprite.position.y - 100, 'invisible_block');; childSprite.pivot = this.pivotSprite.position; childSprite.body.angularVelocity = 50; this.pivotSprite.addChild(childSprite); var bat = new Bat(game, 0, 0); bat.follow = childSprite; So, the point is, the childSprite will rotate around a pivotSprite, and my bat will follow that childSprite. But, the problem is that when I use "Phaser.Physics.Arcade.moveToObject(bat, bat.follow, 100)" the bat goes to the initial position provided in "var childSprite = new Phaser.Sprite(, 0, this.pivotSprite.position.y - 100, 'invisible_block');" and stay there. I'm using the Phaser.debug.body to check the child, and she is really moving around the pivotSprite. Is that right? Because I was wondering that childSprite and bat.follow would be the same object.
  5. nicoloko02

    Sprite doesn't collide using map.putTile

    If someone is having troubles to test the collision like I was doing, I found a solution for my problem. For this, I separated the walls and floor in diferent layers, then started to use "this.physics.arcade.collide(person, wallLayer);" in the update function, that way worked very well. =-)
  6. Greetings!!! It's my first time here. So, my problem is, when I use map.putTile, I set the collidable tiles using map.setCollisionByExclusion([6]), but it's not working. Let me show a piece of code here: game.physics.startSystem(Phaser.Physics.ARCADE); mapa = MapGen.gerarMapa([0, 50, 50, 45, 5, 0, 5]); game.stage.backgroundColor = '#2d2d2d'; map = game.add.tilemap(); map.addTilesetImage('dungeon'); layer = map.create('mapa', 50, 50, 32, 32); for (var x = mapa.length; x-- { for (var y = mapa[x].length; y-- { if (mapa[x][y] == '.') { map.putTile(6, x, y, layer); } else { map.putTile(14, x, y, layer); } } } layer.resizeWorld(); map.setCollisionByExclusion([6]); personagem = game.add.sprite(100, 82, 'personagem'); game.physics.enable(personagem); personagem.body.setSize(50, 41, 25, 20); personagem.body.collideWorldBounds = true;This code is in my create function, so, basically, I generate my map using "MapGen.gerarMapa([0, 50, 50, 45, 5, 0, 5]);" and I'm using "map.putTile(6, x, y, layer);" to put the floor, and "map.putTile(14, x, y, layer);" to put the wall, then I say that the just the tile 6 won't collide using "map.setCollisionByExclusion([6]);". That's it, if anyone can help me solve this problem I would be very grateful.