Rydez

Members
  • Content count

    26
  • Joined

  • Last visited

  1. Arcade physics friction??

    Oh, cool! I didn't know that. Might refactor some code to use drag rather than manually setting the acceleration.
  2. Arcade physics friction??

    You're heading in the right direction. But, it seems like friction is only in the box2d plugin. You have several options. - You could set the velocity to zero when the controls aren't activated. - You could decelerate the player when the controls aren't active. - You could roll your own friction code. This would require some understanding of physics. - You could purchase the box2d plugin. Personally, I'd go with the second option of decelerating the player. It's simple and effective for simulating the presence of friction. You could determine the player's direction and set the acceleration in the opposite direction.
  3. how to call a function after sprite moves?

    I'm curious how you are attempting to log the coordinates. You mentioned trying to log the game height, but this will not give you the coordinates of a sprite in the game. If you want the coordinates of a sprite named mySprite, then you could use mySprite.x and mySprite.y. An example of the code you are using to log the coordinates might help in determining a solution.
  4. Exact walking animation

    Ooo, I like that next() method. Cleaner and more Phaserish than my if-else. I'm pretty sure the physics will be completely independent of the animation technique you use. i.e., you wouldn't be missing out on arcade physics. This example uses arcade physics without any animations involved: https://github.com/photonstorm/phaser-examples/blob/master/examples/arcade physics/one way collision.js.
  5. N00B question

    I think I need a better understanding of what you're trying to do in order to say which function. But, probably in the update function. Do you see the update function in the link?
  6. N00B question

    Aloha! What first comes to mind: myObject.y = 50; But, really, there's many answers to this question. Perhaps you want 50px from the original spot rather than "50 px along the y axis", in that case you might prefer: myObject.y += 50; // or myObject.y -= 50; Or, maybe you have something else in mind. I think this link will be helpful: https://phaser.io/examples/v2/sprites/move-a-sprite
  7. Exact walking animation

    Hi jjcale! I'm not exactly sure how you want the character to move, but it seems like you would like to take the animation out of Phaser's hands. Maybe you could try manually changing the frame. Here's some pseudo code to get my point across. number_of_right_walk_frames = 4 pixel_step_size = 4 if (right_arrow_key_is_Down) { player.x += pixel_step_size if (player.frame !== number_of_right_walk_frames - 1) { player.frame += 1 } else { player.frame = 0 } } Is this what you're looking for? Or, am I misunderstanding?
  8. I thought about doing this, but it felt like I wouldn't benefit from it and would be better off just not using any grouping method at all. Adding children to a sprite is convenient because I can treat the different parts (body, head, gun) as a single sprite. Whereas if I use a group, then I will have to manipulate the parts separately, as I would if there was no grouping going on at all. At least, this is my understanding. Albeit naive. I think the main reason I want to stick with the child sprites is that their parent has a body, and groups don't have bodies.
  9. Oh, okay, I see. I think this is the first time that I've used parent sprites like this. Now that I understand, I'm glad that it is the way it is. I might switch to this method, but I think this was actually the source of my confusion. I had originally added sprites to the player sprite which worked as I expected. But, then I couldn't bring the parent sprite in front of the child sprites so I switched to the "blank" sprite as a parent. Then I was confused about the "change" behavior. I don't know who makes the Phaser examples or if they are community contributions, but perhaps an example about this nature would be nice. I think there is only one example about child sprites, and it doesn't illuminate this behavior. But, then again, maybe there are other examples that I'm unaware of that show this. Anyway! Thanks guys!
  10. I have a character with multiple parts. I want them to move as one. So I create a "blank" sprite, then add my sprites character sprites to the "blank" sprites in the order I want them to appear. From searching around, this method seems to be typical. The issue comes when I try to change the widths and heights. For some reason, I have to divide by the parent sprite scale when setting the child sprite size: var parentSprite = Game.add.sprite(Game.width/2, Game.height/2, ''); parentSprite.height = 100; parentSprite.width = 100; parentSprite.anchor.setTo(0.5, 0.5); var childSprite = Game.add.sprite(0, 0, 'dude'); childSprite.height = 100/parentSprite.scale.y; childSprite.width = 100/parentSprite.scale.x; childSprite.anchor.setTo(0.5, 0.5); parentSprite.addChild(childSprite); Perhaps this is necessary, to have the child sprite size relative to the parent. But I could not find this in the docs, and I don't think it's obvious that this should be done. Maybe I overlooked something. For future reference, does anyone know where I could've found this information?
  11. My sprite sheet has strange behaviour

    So I'm not quite sure exactly what behavior you are referring to. Would I be correct in assuming that you're referring to how to character is coming into, then leaving the sprite? If so, I'm fairly confident that it's an issue with your sprite sheet and not your code. If that's not a correct assumption, would mind narrowing down to the problem you're concerned about?
  12. Issue with resize and gravity

    Oooooh, I see. Thanks so much for your help!
  13. Issue with resize and gravity

    Hey samme, wanted to let you know that I've been able to resolve the problem by turning off collision checking at the beginning of the resize function, and turning it back on at the beginning of the update function. I still am not exactly sure why it's necessary to mess with the collision checking, so it feels pretty hackish to me. But it works! Thank you
  14. Issue with resize and gravity

    Okay I put your code in the create function and it changed the behavior. It partially fixed the problem. After resizing, the player is now centered horizontally, but not vertically. It's centered horizontally and vertically if I extend your code to: checkCollision.left = false; checkCollision.right = false; checkCollision.up = false; checkCollision.down = false; But, this won't work as a solution because now there's no collision handling. Would you mind explaining how you came about this? I'm pretty confused.
  15. Hello there! It seems that you're creating a group for the baddies and then you're not filling the group with baddies. That for loop is only redefining your baddie variable. I think you're going to want to keep the baddies group variable and delete the baddie variable. Then add to the baddies group in the for loop. Have a look at this example: https://phaser.io/examples/v2/groups/add-a-sprite-to-group