temporalix

Members
  • Content Count

    16
  • Joined

  • Last visited

  1. temporalix

    Best way to handle npc's that can go in and out of view?

    the way that seems to work best is putting this.birdGroup.forEach(function (bird) { if (bird.body.y > 1868) { bird.y = 1866; } });in the update function. so even when the birds go out of camera view and there is no more tilesprite under them to collide with they will stay at the same height so when they do come back into the camera view they are at the right height and can collide with the ground again, they can also continue moving left or right to get into the camera view where the player is. using outOfBounds and OnEnterBounds to fix bird positions leads to glitchy sprites as the events don't happen exactly when sprites leave/enter, setting their gravity in the events also doesn't work and they end up falling down
  2. temporalix

    Having trouble detecting collisions in my game

    I haven't really tried implementing anything but, can you not use circle instead of rectangle in the collision function ? Phaser.Rectangle.intersects(boundsA, boundsB) -> Phaser.Circle.intersects(boundsA, boundsB); or otherwise perform some kind of logic check in the function like if boundsA !== boundsB then perform the intersect so only seperate circles intersect?
  3. temporalix

    Having trouble detecting collisions in my game

    could using overlap not maybe help? here is a link in examples - http://examples.phaser.io/_site/view_full.html?d=sprites&f=overlap+tween+without+physics.js&t=overlap%20tween%20without%20physics
  4. temporalix

    Best way to handle npc's that can go in and out of view?

    outOfBoundsKill is set to false and checkWorldBounds is currently set to true as i was testing the possibility of saving and loading position on outOf / in Bounds events. what happens is that the sprites end up losing collision with ground tilesprite when they go out of bounds and then with body.collideWorldBounds as true they collide with the bounds below the ground - http://imgur.com/oozuUSZ .
  5. I've got npc's that can go offscreen when player moves left/right but as they go out of bounds collision stops working on ground and they end up colliding with the world bounds, what would be the best way to handle them? do i save their positions on outOfBounds? or disable gravity for them or somehow keep ground collisions working out of camera?
  6. not sure if what is say would work but let me just fire away on an idea: since it is zero gravity and you are using velocity, one way would be to apply velocity in the opposite direction after a set time, so you let the character move in a direction for a second then apply an opposite velocity, and maybe doing this in the same check for direction might be an alternative. Ive had simple things not work because of how the logic was setup.
  7. temporalix

    p2 sprites stop colliding when collideworldbounds=false

    It just seems weird to me that you can have collisions between sprites in a group when there is a boundary but as soon as you remove that boundary they stop colliding with each other. why not make them not collide from the start so that whether there is a boundary or not, you know sprites wont collide. the way i solved this was to make the sprite collision group collide with itself.
  8. Why do p2 sprites in a group collide with each other when collideWorldBounds=true but when I set it to false they stop colliding?
  9. temporalix

    Why does a sprite move down once physics is enabled?

    everything works fine now using latest 2.0.2 Build. Thanks for fixing this rich.
  10. temporalix

    Snake Game

    you can set the body's x and y velocity to equal to variables then change those variables on keypress, eg : physics needs to be enabled on group/sprite in your create function. var xVelocity=0; var yVelocity=0; function update() { snake.body.velocity.x=xVelocity; snake.body.velocity.y=yVelocity; if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { // do the same for other directions changing xVelocity and yVelocity to correct values //set both velocities of body so sprite travels only in single direction xVelocity=-200; yVelocity=0; } //collision handler to change direction on collide with wall game.physics.arcade.collide(snake, wall, collisionHandler, null, this); } function collisionHandler(obj1,obj2) { if(xVelocity==0) { xVelocity=200; yVelocity=0; } else { xVelocity=0; yVelocity=200; } } this code should get you started. there will be a few bugs and problems with movement but that can be fixed by changing or adding in more checks on the snakes velocity or position
  11. temporalix

    Weird Arcade Physics with 2.0.1

    I have the same problem in this topic: http://www.html5gamedevs.com/topic/5071-why-does-a-sprite-move-down-once-physics-is-enabled/ , i have a ball rotating around a sprite, before enabling physics, i can set the pivot and it rotates nicely around the sprite and i can change this pivot which causes the ball to rotate in a larger circle around the sprite, after enabling physics, the balls flies completely off course in a wider circle, and changing the pivot makes it worse. It seems like pivot before and after physics are completely different methods, I've ended up using sprite's base method Overlap to check for some basic collisions until this gets fixed in a later version.
  12. temporalix

    Why does a sprite move down once physics is enabled?

    Tried the latest 'Dev' branch and its still the same . the sprites positioning and pivot are still affected as soon as I enable physics on it.
  13. Hello I have a sprite in a group, before enabling arcade physics the sprite is positioned correctly, but after enabling arcade physics on the sprite, it shifts downwards and the pivot is different? before: sprite1 = game.add.sprite(0, 0, 'balls', 0, spinGroup); sprite1 .pivot.x = -100; to move it to around same position I had to change the code. after: sprite1 = game.add.sprite(5, -115, 'balls', 0, spinGroup); sprite1 .pivot.x = -9; Is this a bug, or am I doing something wrong?
  14. temporalix

    time event loop

    when I've used timer , sometimes its seems like the fps drops or something and things happen sooner or later than what they should be, when I set up bullets to shoot at a constant rate every few seconds there would be lag. It could be that there is only 5 monkeys in the group and they aren't being removed quick enough when out of bounds, try increasing the amount in the group maybe? and see if that helps
  15. temporalix

    tweening to set positions

    I got it working after messing around with it a bit , and seeing that the logic inside the button press loops was interfering with the tweens. I ended up moving all the logic into a seperate function which I think makes is cleaner . code: function getPos(dir) { if (dir == 0) { if (moveX > 100) moveX = moveX - 500; spinSpeed = spinSpeed -5; } else { if (moveX < 1000) moveX = moveX + 500; spinSpeed = spinSpeed + 5; } } left = game.input.keyboard.addKey(Phaser.Keyboard.LEFT); left.onDown.add(function () { getPos(0) }, this); left.onUp.add(function () { leftTween = game.add.tween(ufo).to({ x: moveX }, 1000).start(); }, this); right = game.input.keyboard.addKey(Phaser.Keyboard.RIGHT); right.onDown.add(function () { getPos(1); }, this); right.onUp.add(function () { rightTween = game.add.tween(ufo).to({ x: moveX }, 1000).start(); }, this);