THT DUYURU

 
 
Web Programming Section where Web programming languages are shared

Seçenekler

Creating a Simple Windows 8 Game with JavaScript Part 4

Gauloran - ait Kullanıcı Resmi (Avatar)
Kadim Üye
Üyelik tarihi:
07/2013
Nereden:
local
Mesajlar:
7.290
Konular:
1663
Teşekkür (Etti):
656
Teşekkür (Aldı):
1504
Ticaret:
(0) %
0
359
27-12-2020 20:48
#1
Adding the Remaining Assets

Now that you’ve seen how to add the background. It’s mostly a matter of repetition to include the others (with a bit more math thrown in.) Head back to default.js and include the following in prepareGame():
A few notes on this:

  • The catapults appear at "ground level" which we need to scale along with the overall size of the images
  • Drawing player 2’s catapult is tricky because we need it to face the other direction. Using regX to set a transform point and setting a negative scale gets the job done.
  • We create and add the ammo (boulder) image, but hide it until it’s fired later.
Adding Some Text

To wrap things up for this post, let’s use EaselJS’s Text class to add a game title along with indicators for each player’s remaining catapults. First, we’ll need a few variables near the top of default.js:
Then, add the following to prepareGame();
To the Stage, Text instances are children just like the Bitmaps we added earlier.
What does the game look like now?
What’s Next?

Things are looking pretty good, but unfortunately that’s about it – nothing’s moving. In the next post, we’ll dive in to the game’s mechanics, fleshing out the game loop by adding motion, collision detection, scorekeeping, and the endgame.
--------------------- more than you know
- Teşekkür etti.

Bookmarks


« Önceki Konu | Sonraki Konu »
Seçenekler