-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Strange rendering issues #7051
Comments
@vladilen11 your link doesn't work! |
Sorry, pls try again. https://github.com/vladilen11/monster-demo/blob/main/apps/web/game/scenes/battle-scene.ts#L44-L68 pnpm i && pnpm run dev
visit http://localhost:3000/game |
not able to get it running @vladilen11 . if it's still an issue, maybe provide a slim version of the issue. |
@kpotschi I'm trying ts template to run the project, I think the current version is already minimalist in ts project. Could you try going into apps/web and running |
I couldn't get the original code base running, probably because I don't have I do question how the fonts are being set though - you aren't passing them in via the If you change your battle-scene code to something like this:
what does it print out? Does it print out Also, does it fix the issue if you add Without simplified code that is easier to run that replicates the issue, it's a bit hard to narrow down the culprit. |
@Stever1388 You can try downloading I tried the way you provided and it prints I tried setting the ![]() |
@vladilen11 For the issue you are seeing, I believe this is a React issue and is tied to how the game is getting re-rendered. In your code here: https://github.com/vladilen11/monster-demo/blob/main/apps/web/game/phaser-game.tsx#L19 if (ref.current === null) {
const game = StartGame('game-container');
ref.current = { game: game, scene: null };
} if you replace this with: if (ref.current === null) {
const game = StartGame('game-container');
// ref.current = { game: game, scene: null };
if (typeof ref === 'function')
{
ref({ game: game.current, scene: null });
} else if (ref)
{
ref.current = { game: game.current, scene: null };
}
} The issue goes away for me when I run the app locally. test.movI wish I could provide more context on why this fixes the issue, but I have limited experience with React. For the code, I used the Phaser Next.js template as reference: https://github.com/phaserjs/template-nextjs/blob/main/src/game/PhaserGame.tsx#L25, and this fixed the issue for me. |
@scottwestover Thank you for your reply, and also a special thanks for the excellent instructional video you produced. |
@scottwestover But there should still be a problem with this, This code doesn't actually set the correct game object under ref.current. This is my debug log: because my code game is a Pharse.Game instance. I think it's need to change it to that as well: if (ref.current === null) {
const game = StartGame('game-container');
// ref.current = { game: game, scene: null };
if (typeof ref === 'function')
{
ref({ game: game, scene: null });
} else if (ref)
{
ref.current = { game: game, scene: null };
}
} But if we change it to this, it will still have this rendering problem. Also, I've tried replacing it with the contents of the official PhaserGame.ts, but I still have this problem. |
Got it. As I mentioned, I have limited experience with React, but if I get some time, I will try to take a look at the issue. If you haven't yet, it might be worth asking about this issue on the Phaser Discord, and on the Phaser Forums for more visibility. |
version:
^3.87.0
Description
I set a text in the page with no background, but it's inexplicably has a black background.
this is my code:
You can see in the image above that
L5
appears to have an inexplicable black background. And when I do replace the code forHP
andL5
, the black background appears forHP
and not forL5
. Why is this? I've tried many things and can't find the problem.this is my code: https://github.com/vladilen11/monster-demo/blob/main/apps/web/game/scenes/battle-scene.ts#L44-L68
you can test it with this repo.
The text was updated successfully, but these errors were encountered: