• Content Count

  • Joined

  • Last visited

About P4UL

  • Rank

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I didn't knew this is possible, thank you very much!
  2. I had not thought about class inheritance. In the meantime I tried to store the name of the next tilemap in a global variable and reading this variable in the create function. It worked but your idea is much better and cleaner. I will rewrite my code to use class inheritance for the states, thank you very much!
  3. Hello! I have a game with multiple states. The logic in all states is the same. The only thing that changes is the tilemap used in the create function. All other objects are the same in all states. I could simple duplicate one file with the state for every tilemap. Is there an easier way to do this? I would really like to re-use one state for all tilemaps. As far as I understand how states work the create function will be called every time the state is started. So I believe there must be a way to give the name of the tilemap as a parameter to the create function or something similar. Thanks in advance!
  4. The difference of the two examples is that the first examples uses states and the second one does not use states. If you only have one state it does not really matter wich example you chose, but when you add multiple states you will need the first example. You can then create multiple states (for example one for the menu and two levels). This makes it also very easy to break up the code into multiple files, so that you have a seperate file for every state.
  5. Thank you very much! I already used a sprite pool for bullets, but I simply forgot that I could use it for other things than bullets. The other approach with the bitmapData seems very good. I think I will use that. Thank you for the link!
  6. Hello! I have a Tilemap and two objects. The first object willl calculate the shortest path to the second one. If the player hits enter, the object will use this path. Before the player will press enter I want to show a preview of the path. How would I do this? I could simply create a new Sprite for every point in the path and set the position to that point. The path will be recalculated very often, so I would permanently destroy the path sprites and recreate them. Is there a better option to achive this? Thanks in advance!
  7. I updated the fiddle: https://jsfiddle.net/t2pytweb/12/ To align the lines in the center of the circles I changed the sprites anchor. The anchor of the circles is set to 0.5 for x and y. So the x and y position of the points is exactly in the center of the point. The anchor of the lines is set to 0.5 for x and 0 for y. Because of the 0.5 for x the vertical align is in the center of the line. And because of the 0 for the y anchor the horizontal position is still on the left side of the line (so you can position it at the start point). I attached an image so you can better see where the anchors are. I also changed the size and color of the points and lines in your example so that it is easier to see that the lines are correctly aligned to the center of the points. The code that updates the lines every frame is now in the update function. The render function is for rendering (and for example for displaying debug information). So the update function is better for this.
  8. Happy to help! I updated your fiddle. I added phaser as an external resource and I removed the game.debug.geom(point). You are using sprites for the points, so there is no need to show them in the render function with game.debug.geom(). Link to the updated fiddle: https://jsfiddle.net/t2pytweb/7/ Changing the colors is a nice idea. I have some ideas for further improvements: I think it is better to use sprites for the lines. You could create a simple texture for this and scale it up (only the x scale) to be exactly as long as the distance between the points. Then place it between the two points and rotate it towards the points.
  9. I created a js fiddle how I would do it: https://jsfiddle.net/o9cf5zt6/10/ It basically creates all the lines in the create function. Each line holds a reference to its start and end points. In the render function is a for loop that iterates over every line and calculates the distance between the start and end points. If close enough, it updates the line and renders it. (Please keep in mind that I am also really new to phaser, so there could be better ways to do this) It would be helpful to see your code. In your screenshot some close points are not connected, is that what you want? If not how do you calculate wich lines should be drawn?
  10. I have an idea but I do not know if it is very efficient. You could do something like this: 1. Create a line from every point to every other point and hold references to them in an array (in the create function). 2. In the update function calculate the distance between the points. 3. If two points are close enough then update the line start and end points and show the line. if the points are too far away then hide the line. I do not know if this is a good way to do this because you will have many lines. On the other hand you only create the lines once and reuse them with this approach.
  11. Thank you very much for your answer! The "outOfBoundsKill" property worked perfect for me and the code is much cleaner than iterating over every bullet.
  12. Hello! I have a custom actor (extended from Phaser.Sprite) that is controlled by the user. I want the actor to be able to shoot the children of a enemies group. To do this I create a new sprite every time the user wants to shoot and add it to a bullets group. The sprite is accelerated in the direction that the actor is looking to. Everything works fine, and the bullet and the enemy get killed if they overlap. When the bullet overlaps somthing different than an enemy only the bullet gets destroyed. The Problem is that the bullets will not be destroyed if they reach the world bounds. Is there any way to detect collision between the bullet sprite and the world bounds? Is there a built in way to do this? If not, what is the better practice: Iterate over every bullet (most time not more then 10 bullets at the same time) in the update function to check if it has left the world Create invisible sprites at every world border and check for collisions between them and the bullets I am new to this forum and also new to phaser. Sorry if the answer to my question is very simple. Thanks in advance, Paul