tailieunhanh - ActionScript 3.0 Game Programming University, Second Edition phần 8

Các lĩnh vực văn bản chúng tôi sẽ thiết lập sẽ sử dụng một định dạng văn bản đơn giản cho phông chữ Courier, 30 điểm. Nó sẽ thiết lập chiều rộng và chiều cao để các văn bản sẽ không can thiệp với Hangman đồ họa bên phải. Chú ý Lý do tôi chọn Courier là nó là một phông chữ monospaced. Điều này có nghĩa là mỗi chữ cái | 390 Chapter 11 Action Games Platform Games or right however we move the entire gamelevel movie clip to make it scroll. The rest of the code can ignore this because nothing actually moves inside the gamelevel. Planning Which Functions Are Needed Before we begin programming let s take a look at all the functions that we use in the class and which ones rely on each other. startPlatformGame Initializes the score and player lives. startGameLevel Initializes the level calling the next three functions createHero Creates the hero object looking at the placement of the hero movie clip instance. addEnemies Creates the enemy objects looking at the enemyX movie clips. examineLevel Looks for walls floors and other items in the gamelevel movie clip. keyDownFunction Notes key presses by the user. keyUpFunction Notes when the user is done pressing a key. gameLoop Called every frame to calculate the time passed and then call the next four functions moveEnemies Loops through all enemies and moves them. moveCharacter Moves the character. scrollWithHero Scrolls the gamelevel movie clip depending on the location of the hero. checkCollisions Checks to see whether the hero hit any enemies or items. Calls the next three functions enemyDie Enemy character is removed. heroDie Hero loses a life game possibly over. getObject Hero gets an item. addScore Adds points to the score displays the score. showLives Shows the number of lives left. levelComplete Level is done pause and display dialog. gameComplete Treasure is found pause and display dialog. clickDialogButton Dialog button clicked perform next action. cleanUp Removes the gamelist to prepare for the next level. Now that we know the functions we need to write let s build the class. Wow eBook Building the Class Í391 Building the Class The package file is not particularly long especially considering all that this game does. Because of that we keep everything in one class even though it can be useful for a larger

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.