Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game crash in background render #4

Open
MarioMey opened this issue Jun 3, 2015 · 2 comments
Open

Game crash in background render #4

MarioMey opened this issue Jun 3, 2015 · 2 comments

Comments

@MarioMey
Copy link

MarioMey commented Jun 3, 2015

Sometimes, after 9 seconds of playing (the first curve to the left of the array of towers), all the sprites dissappear and I have this in Firefox console:
IndexSizeError: Index or size is negative or greater than the allowed amount
in common.js, line 287:
ctx.drawImage(background, sourceX, sourceY, sourceW, sourceH, destX, destY, destW, destH);

captura de pantalla de 2015-06-01 09 25 08

@MarioMey
Copy link
Author

MarioMey commented Jun 3, 2015

Before line 287, I added:
console.log(background, sourceX, sourceY, sourceW, sourceH, destX, destY, destW, destH);
to debug it. Before the bug arrived (at second 9.1), the last lines logged were:
...
< img src="images/background.png"> 5 985 640 480 0 19.11709921839087 1024 768
< img src="images/background.png"> 5 495 640 480 0 6.397193056316348 1024 768
< img src="images/background.png"> 5 5 640 480 0 12.794386112632695 1024 768
< img src="images/background.png"> 1285 985 0 480 0 19.191579168949044 0 768
IndexSizeError: Index or size is negative or greater than the allowed amount

I don't understand so much... but it seems that drawImage does not accept 0 as destiny width... and Render.background is trying to do that.

@MarioMey
Copy link
Author

MarioMey commented Jun 5, 2015

I made a workaround using try-catch... it only pass by the error, the game doesn't crash, but it is not the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant