0

I'm following a HTML5 game tutorial on MDN. In JavaScript whenever my game loop re-calls its-self with

requestAnimationFrame(gameLoop);

There

fillSytle = "someColor";

option of one the functions being called in my game loop changes the color of every other shape unless I give all the shapes same color.

How can I give different styles or colors to different shapes in game Loop?

Ahmad
  • 2,629
  • 3
  • 22
  • 27
  • You only get only 1 styling (`fillStyle`) per single path. A single path is started with `beginPath`. Solution: Use `beginPath` for each shape so you can set each path's fill color. – markE Mar 27 '16 at 17:45
  • You didn't get my question. I do use beginPath and closePath for every path(shape) separately but still when the second time gameLoop runs the first function's fillStyle dictates every shape then the next one then the next and so on.. – Ahmad Mar 27 '16 at 20:26
  • If that's the case then you didn't give us enough info to help you with your problem (you gave 2 lines of code and a narrative). Open a new question including the relevant code. :-) – markE Mar 27 '16 at 22:40

0 Answers0