 # CodedGames

Members

31

• Rank

## Contact Methods

• Website URL
http://www.codedgames.com
@CodedGames

## Profile Information

• Gender
Male
• Location
Lakewood
• Interests
Coding, writing blog posts, other game dev things.

## Recent Profile Visitors

1176 profile views

• ### -AAG-

1. ## Changing game.world.angle doesn't affect Arcade bodies.

So I'm trying to rotate everything using game.world.angle. I thought I would still be able to use the arcade physics system because, even though things are rotating, the underlying coordinate system is never changed. But, as you can see, when I rotate the entire world, arcade bodies remain unchanged. Any idea to get around this other than switch over to the P2 physics system? Update: So I found that the body.rotation variable is changing. I think that is the problem
2. So this seems like it should be fairly simple, I want the camera to always follow the player even if they go outside the bounds of the map. How would I do that?
3. Ok thanks guys I got things fixed. The problem was that I calculated the distance between two points, adjusted the x position, then calculated the distance again when adjusting the y position. This caused things to have their distance from the pivot point changed when it shouldn't. The only thing left is I need to get collisions to work with rotated sprites. Originally I was using the arcade physics but I heard I need to switch over to P2 for rotation to work.
4. ## phaser Rotating walls around the player.

Hello, so I'm trying to make it so that the player can 'rotate' the camera around them. For example when they press E and Q the world rotates and things like walls get repositioned and their angle changes. Here is the code I have written: function rotateWorld(angle) { for (var i = 0; i < walls.getAll().length; i++) { var wall = walls.getAll()[i]; wall.angle += angle; var delta_x = wall.x - player.x; var delta_y = wall.y - player.y; var thetaAngle = Math.atan2(delta_y, delta_x) * 180 / Math.PI; wall.x = player.x + lengthdir_x(distance(wall.x, player.x, wall.y, player.y), thetaAngle + angle); wall.y = player.y + lengthdir_y(distance(wall.x, player.x, wall.y, player.y), thetaAngle + angle); } } function lengthdir_x(length, direction) { return Math.cos(direction * Math.PI / 180) * length; } function lengthdir_y(length, direction) { return Math.sin(direction * Math.PI / 180) * length; } function distance(x1, x2, y1, y2) { return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); } So far this sort of works but objects lose proper positioning after rotating a bit. It seems like they are not rotating around a perfect circle. Any help would really be appreciated and if there is a way to do this that's easier please let me know. Thanks!
5. ## New to Phaser, trying to break the player into it's own class.

Ok awesome, the game will now run. That got rid of that error message. The only problem I'm running into now is that the player is not showing up in the game. Is that valid to call game.add.sprite(this); in the constructor of player? The object is getting instantiated, I can see that it is in the proper position using console.log but it doesn't seem to be affected by gravity and cannot move around. The sprite itself is also not being drawn. Edit: Got it, you have to call game.add.existing instead of sprite.
6. 