Skip to main content
New
Stack Overflow Jobs powered by Indeed: A job site that puts thousands of tech jobs at your fingertips (U.S. only). Search jobs
4 votes
Accepted

Point plotting with a line graph

You can solve this with some basic trigonometry. I wrote the code in Unity, but the general idea should be the same. Consider the following image: We already have P1 and P2. Here is some code to ...
jgallant's user avatar
  • 8,424
3 votes

How do you do tile-based movement in Phaser?

The player should have a position, that can be any number, and a target position. When the current position is equal to the target position, check the input, and set the new target position ...
Bálint's user avatar
  • 14.9k
3 votes

Why can't i change the background color in Phaser?

If you want to change the background color for the whole game, it´s easier to just set it in the game config. You can even use transparency: ...
andyrandy's user avatar
  • 141
3 votes

Pathfinding in Isometric Phaser with Tunnels

I disagree that you have to have a 3D map for this, and depending on how far along you are and how you implemented things, it might be a lot of work or bring other problems if you try to convert your ...
Christian's user avatar
  • 2,067
3 votes

Is it possible to make a pseudo isometric game with phaser?

Phaser handles this out of the box using sorting based on the y index. I have used this exact technique too to create stacked sprites so the elements at the bottom of the screen are drawn over the ...
BobGneu's user avatar
  • 222
3 votes
Accepted

One pixel lines flash on tile map when camera moves

I was able to fix the problem by setting following a point instead of following my hero sprite. The core problem was the camera wasn't moving in round pixels. By making that point move in round pixels ...
Erik's user avatar
  • 161
3 votes
Accepted

Phaser 3 - How to trigger an event every 1 second?

In your scene's update method you receive both the current timestamp, and the delta since the last update call (see https://photonstorm.github.io/phaser3-docs/Phaser.Scene.html#update__anchor) You ...
vassildador's user avatar
3 votes
Accepted

Algorithm for taking the shortest path between two XY coordinates

Your code makes him move vertical and horizontal if needed. He moves the same speed both vertical and horizontal, that's why you only get a 45 degree angle. He moves like this until there is no need ...
agiopnl's user avatar
  • 146
2 votes
Accepted

Does Phaser Arcade.Body velocity include deltaTime or not?

Well.... I think I'm stupid... My calculation of the deltaTime was wrong The correct formula will be ...
Alexey Shimansky's user avatar
2 votes
Accepted

How to kill a fired bullet sprite after certain amount of time in Phaser?

I found out that objects can be killed with body.lifespan Adding the line bullet.lifespan = 1000; in my ...
flufflepuff's user avatar
2 votes

Pathfinding in Isometric Phaser with Tunnels

So you might be rendering in 2d, but effectively by doing this your game map is no longer 2d, it is in fact 3d. You could handle this by pathfinding in three dimensions. Assuming a 3x3 grid with a ...
Macha's user avatar
  • 121
2 votes

add physics to a group or container body in phaser

I think you can't do it. Phaser groups doesn't have body: http://phaser.io/docs/2.4.4/Phaser.Group But you can use setAll method to set properties to all sprites of a group: http://phaser.io/docs/2....
jolmos's user avatar
  • 171
2 votes

Take an image and cut it up into a tile map

Take a look at Tiled. It's a tool for creating 2D tile maps including hex-based maps like the example in your post. Phaser allows you to load tile map data generated by this tool. Once you've created ...
JRR's user avatar
  • 21
2 votes
Accepted

Component based architecture in TypeScript

I've got some good suggestions on Phaser forum, the solution shown by user @flyovergames was what I was looking for: ...
Guilherme Recchi Cardozo's user avatar
2 votes

Why are not the images loaded in Phaser?

I tested your Phaser Javascript code and it works fine. So I'm thinking it's a problem with how you've set up your server. Look up Express.js, its an NPM module that makes it really easy to set up ...
Dabe's user avatar
  • 21
2 votes
Accepted

Whay can my player only move in one direction?

I think your problem is that your understanding of if and else is slightly wrong. ...
Philipp's user avatar
  • 120k
2 votes
Accepted

How to justify text that appears character-by-character

I don't know what functionality Phaser offers, so this answer is abstract, but in general you must lay out the full text (or at least the entire next word for ragged-right and the entire next ...
Kevin Reid's user avatar
  • 5,498
2 votes
Accepted

How to make object movable only by the player?

If you want to use the builtin phaser functions, you just need to create a phaser-matter-gameboject, like an image (link to the documentation), and that you configer it to be draggable. create matter-...
winner_joiner's user avatar
1 vote

phaser.io mouse cursor sprite

You can use JavaScript's pointer lock API. First of all, it's still an experimental feature, so to be sure, you might need to check for compatibility and make sure there's a single working function: ...
Bálint's user avatar
  • 14.9k
1 vote

Phaser problem with .damage oneshots

zombies is a Group. You should set health on each individual zombie. By the way, your ...
congusbongus's user avatar
  • 14.8k
1 vote

Rotating a group of bodies in Phaser

A solution for the ships colliding after being added to the shipgroup is to call enemy.body.clearCollision() before adding it to the shipcollisiongroup. To not have them all go to the same place you ...
Erik's user avatar
  • 11
1 vote
Accepted

Collision not working in phaser node multiplayer

Make sure you're sending the velocity of your physics bodies from the server too. Position alone won't cut it, because it's not the only thing that impacts how the game objects move. The most secure ...
Hexus's user avatar
  • 126
1 vote

How do I get an attribute of a function?

You absolutely can. Just change what's returned and how you interact with it. ...
James Skemp's user avatar
1 vote

How to transfer drag control from one sprite to another? (Phaser)

Without code I'm not exactly sure what you're doing for the dragging now. So, I see two options: Spawn a new sprite where the old one was before and let the one that was being dragged continue to be ...
James Skemp's user avatar
1 vote

Phaser Shooting Game

I know very little about Phaser, but for my pure JS/canvas projects I handle key input with eventListeners. Here is how I do it: ...
Grufkork's user avatar
1 vote
Accepted

Phaser game is not registering collisions and input - but only on my machine

I was able to solve it by clearing my local cache in my browser history. Lesson learnt: clear the cache if weird localised problems happen.
Felix O'Brien's user avatar
1 vote

setSize in Phaser.io

It doesn't look like you're initializing the physics anywhere. If you're trying to set attributes on the 'body', the body will be null unless you've initialized a physics engine on the sprite. Do ...
HaywardMorihara's user avatar
1 vote

Loading maps on HTML5 Games

That depends on how you load your maps and how long it takes. Depending on how it is programmed, a Javascript application can either start downloading a resource on pageload or when it actually needs ...
Philipp's user avatar
  • 120k

Only top scored, non community-wiki answers of a minimum length are eligible