## 課題: ゲームの初期セットアップ ## タスク: ゲーム内で使う定数や変数を定義します。(DISP_SIZE, FPS) ゲームのコアを作成します。このとき、ディスプレイ(DISP_SIZE)のサイズ(640)も指定します。 cpre.fpsを60にします。 ゲームで使用するすべての画像をプレロードします。 rootSceneに「GAME START」という文字を真ん中に表示します。 ## ヒント rootSceneの背景の色を黒にしましょう。 coreを640✖︎640の大きさで作りましょう。 ゲームで使う画像を全て用意してpreloadしましょう。 (PADDLE, BALL, BRICK) label(文字のクラス)を使って文字をインスタンスしましょう。 ## 使用コード rootScene.backgroundColor = 'black'; const MOVE = 50; const MOVE_SIZE = (SIZE - (SIZE % MOVE)) - MOVE; ### 開始コード: enchant(); document.onkeyup = function (e) { core.press = false; return true; }; function keyPress(key) { var press = false; if(key && !core.press) { core.press = true; press = true; } return press; } window.onload = function() { //ここにコードを記述 core.start(); } <details> <summary>解答</summary> enchant(); document.onkeyup = function (e) { core.press = false; return true; }; function keyPress(key) { var press = false; if(key && !core.press) { core.press = true; press = true; } return press; } window.onload = function() { const SIZE = 640; const FPS = 60; const MOVE = 50; const MOVE_SIZE = (SIZE - (SIZE % MOVE)) - MOVE; const PADDLE = "res/paddle.png"; const BALL = "res/ball.png"; const BRICK = "res/brick.png"; core = new Core(SIZE, SIZE); core.preload(PADDLE, BALL, BRICK); core.fps = FPS; core.onload = function() { var rootScene = new Scene(); rootScene.backgroundColor = 'black'; core.pushScene(rootScene); var gameStartLabel = new Label("Game Start"); gameStartLabel.color = 'white'; gameStartLabel.font = '48px sans-serif'; gameStartLabel.x = (SIZE - gameStartLabel.width) / 2; gameStartLabel.y = (SIZE - gameStartLabel.height) / 2; rootScene.addChild(gameStartLabel); } core.start(); } </details>
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up