جواب «Step 2: The Name» چالش 2 از جلسهی 4
سؤال
حالا اسم بازی:
- یک متغیر title با اسم بازیات بساز، مثلاً const title = "Star Catcher"; (اسم خودت را هم میتوانی بگذاری).
- متن را سفید (white) و با فونت "bold 40px sans-serif" بنویس.
- textAlign را "center" کن و اسم را در (180, 160) بنویس تا درست وسط بیفتد.
راهنما
بعد از پسزمینه: const title = "Star Catcher";، ctx.fillStyle = "white";، ctx.font = "bold 40px sans-serif";، ctx.textAlign = "center"; و ctx.fillText(title, 180, 160);.
یک جواب درست
<script>
const ctx = salam.canvas(360, 480);
ctx.drawImage(salam.image("night"), 0, 0, 360, 480);
const title = "Star Catcher";
ctx.fillStyle = "white";
ctx.font = "bold 40px sans-serif";
ctx.textAlign = "center";
ctx.fillText(title, 180, 160);
</script>
اول خودت امتحان کن؛ جوابهای دیگر هم قبول است. برگرد و خودت حلش کن