by Guest » 19 Jan 2025, 20:54
Ich habe die folgende game.mjs-Datei mit dem folgenden Code
Code: Select all
import Player from './Player.mjs';
import Collectible from './Collectible.mjs';
const socket = io();
const canvas = document.getElementById('game-window');
const context = canvas.getContext('2d');
const load = () => {
context.fillStyle = "#000000";
context.fillRect(0, 0, canvas.width, canvas.height);
context.font = "30px Comic Sans MS";
context.fillStyle = "red";
context.textAlign = "center";
context.fillText("Coin Race", 100, 30);
context.strokeStyle = "yellow";
context.strokeRect(5, 35, canvas.width - 10, canvas.height - 40)
}
load();
Ich habe das Folgende in der Datei index.html
Code: Select all
Secure Real-Time Multiplayer Game
Secure Real Time Multiplayer Game
Die externe Datei wird nicht mit dem Skript-Tag ausgeführt, aber wenn ich den Code direkt in die HTML-Datei im Skript-Tag einfüge, funktioniert es.
Kann Sag mir bitte jemand, was ich falsch mache.
Mir fällt auf, dass das externe Skript ausgeführt wird, wenn ich das Folgende in game.mjs auskommentiere
Code: Select all
import Player from './Player.mjs';
import Collectible from './Collectible.mjs';
const socket = io();
Vielen Dank
Ich habe die folgende game.mjs-Datei mit dem folgenden Code
[code]import Player from './Player.mjs';
import Collectible from './Collectible.mjs';
const socket = io();
const canvas = document.getElementById('game-window');
const context = canvas.getContext('2d');
const load = () => {
context.fillStyle = "#000000";
context.fillRect(0, 0, canvas.width, canvas.height);
context.font = "30px Comic Sans MS";
context.fillStyle = "red";
context.textAlign = "center";
context.fillText("Coin Race", 100, 30);
context.strokeStyle = "yellow";
context.strokeRect(5, 35, canvas.width - 10, canvas.height - 40)
}
load();
[/code]
Ich habe das Folgende in der Datei index.html
[code]
Secure Real-Time Multiplayer Game
Secure Real Time Multiplayer Game
[/code]
Die externe Datei wird nicht mit dem Skript-Tag ausgeführt, aber wenn ich den Code direkt in die HTML-Datei im Skript-Tag einfüge, funktioniert es.
Kann Sag mir bitte jemand, was ich falsch mache.
Mir fällt auf, dass das externe Skript ausgeführt wird, wenn ich das Folgende in game.mjs auskommentiere
[code]import Player from './Player.mjs';
import Collectible from './Collectible.mjs';
const socket = io();
[/code]
Vielen Dank