Questions tagged [html-canvas]
A new feature of HTML5, allowing Javascript apps to have a drawing surface in the browser.
395 questions
0
votes
0
answers
61
views
Android canvas clipping rectangle showing on canvas draw call with paint object that has blurmaskfilter and shadowlayer
I created a game using xml and views on Android. Yes, I know it was not the best choice of development for a 2d game. But, my game is turn based, so mostly static. You can test the game out here: ...
1
vote
0
answers
60
views
Develop a dialogue system for a game in html 5 canvas
similar to rpgs with a popup window and text options. like stardew valley. Are there any common approaches to implement this?
0
votes
1
answer
246
views
Camera movement with player
I'm developing a game using the html5 canvas, but I've never used it before and I'm having difficulty creating a camera. The intention is that it is the same as agar.io, where the player is centered ...
0
votes
0
answers
84
views
Handle roads following in a javascript game
In a browser game made in HTML5/Javascript, I would like to handle the move of units in real-time. But units would have to follow some predefined roads...
Canvas seems better than svg to handle ...
0
votes
0
answers
183
views
Unity WebGL Game's Canvas UI scale changes with windows scale
So this is the setting that is affecting my game. My game is a webgl build from unity running in chrome, hosted on itch.io.
At 100% windows scaling setting, the UI elements have expected size,...
0
votes
1
answer
93
views
Why is this code keeping the listener which should be removed instead?
I am having some issues figuring out why this code still lets btn_1 call the function setstate3().
There is a function ...
1
vote
1
answer
1k
views
How to fit game to screen size?
I create a WebGL game. After building project I discovered that the game doesn't fit the screen size
How you can see the canvas is perfectly scaled but the game didn't
I don't know what I changed but ...
0
votes
1
answer
200
views
How to spread circles evenly around a point?
In my game there's a part where a bunch of circles need to evenly spread around a point. Like in this demo below:
...
0
votes
1
answer
88
views
How do I go about creating images, which are units with traits?
Lets say there are 5 units, displayed as images on an html5-canvas.
Each image (unit) has a different size. For the game I need to know the size of that unit, and also it's middle point.
How and where ...
0
votes
1
answer
150
views
How to add a texture that follows the movement?
I would like to move my landscape to simulate a world moving on the x-axis. I use createPattern() to add an image inside my path, but the pattern draws the image at ...
3
votes
0
answers
1k
views
What is causing my touchstart event to end while I'm still touching the screen, and how can I fix that?
What I'm trying to do:
I'm trying to add touch controls to games created with the html canvas and JavaScript so that they can be used on mobile / tablet devices.
The controls should simply move a ...
0
votes
1
answer
2k
views
find one meter to scale in earth heightmap
I have a heightmap that scales from 0 to 255. the map is only for elevation (discluding water and ice) what would be the appropriate way to calculate the scale of one meter? heightmap below
0
votes
1
answer
124
views
using javascript canvas.context.scale resets custom font
I am making a HTML5 game using javascript with canvas.
I am implementing a custom font adding @font-face style tag to header in the .html file, then if I set ...
1
vote
1
answer
1k
views
Help me Make Sense of Unity 2D Resolution Management
I am trying to set up an environment for a retro style pixel art game in Unity 2D. I aim for a vertical resolution of 240 pixels, and then, I would like the horizontal resolution to be dependent on ...
2
votes
2
answers
3k
views
Performance of many canvas drawImage calls is very slow
I'm developing a top-down 2D tile-based canvas game. I have a single sprite sheet of all my tiles, and then a JSON tile map array of where they're placed.
Previously I would render all the layers of ...
0
votes
1
answer
55
views
Line strokes also adding borders to other shapes?
When you run the project, you can see that the first circles have a black border around them. When I remove the Game.drawLines(), the circles don't have the border ...
3
votes
3
answers
3k
views
What is the "Unity" way to approach tech design for a 2D game like this?
So I come from C++ land where I've always done every little thing myself. Now I'm getting into Unity and C# and I'm ironically overwhelmed with the domain. I'm starting off with this simple little 2D ...
1
vote
1
answer
1k
views
My HTML Canvas went blank
I tried to draw Mario Sprites in my HTML Canvas, but it always went blank.
Anybody knows why?
...
2
votes
2
answers
5k
views
My HTML canvas keep flickering
I'm trying to create a game in HTML canvas, but somehow it keeps flickering, I've taken a look at the tutorial and I perceived that my code is more or less similar. Can anybody help me fix this?
<...
0
votes
1
answer
451
views
how to join the body of snake in 2D snake game
i'm making a snake game in javaScript from scratch. The problem is that the snake looks disjoint(see image). How can I connect the body(rectangles) of the snake?
here is the code of drawing snake:
<...
0
votes
0
answers
38
views
Platformer collision detection problem - player snapping onto sides [duplicate]
I am having problems with collision detection. I am trying to make a simple platformer but when the player is falling or moving too fast it sometimes detects the wrong collision side. I am getting the ...
-1
votes
1
answer
2k
views
Calling setInterval from requestAnimationFrame causes enemies to shoot continuously
I am making a 2D canvas game in JavaScript. I am trying to make the enemies shoot a bullet every 3 seconds.
...
0
votes
1
answer
913
views
How do I change the level of my game by changing the file loaded?
I am making this 2d canvas game in JavaScript and I want to switch to file level2/level2.html when the boss of level 1 (...
1
vote
0
answers
74
views
Problem with collisions detection on canvas platformer
Having a lot of trouble with my collision detection in my platformer. If you go straight to the right the block will float. Also the corners let the block sink right through and the walls are sticky. ...
-1
votes
2
answers
644
views
I need help with calculating the angle my character is aiming at
So im doing this program where i want my hero to shoot to the direction its facing , but for this job to get done i need to calculate the angle my hero is facing with Math.atan2() , atleasts thats ...