169,818
Views
Beginner
Level
94
Comments
Crash Course 2: Invaders - Part 15
by Hectate (Updated on 2015-05-02)
Part 15: Final Touches
Step 102: Now that you’ve tested your game and everything works, it’s time to export it to your desktop as a SWF file. That way, you can open the file in any browser to play the game! Open the Publish menu, select Web, Flash.

Step 103: Stencyl will create a SWF file and ask you to choose where to save the file and what to name it.
Congratulations! Now that you have your Crash Course game, you can take on the Challenges that follow, and modify the Crash Course game further, or you can start on your own game! The choice is yours.
Here are a few challenges you could take on if you want to take this project further. We won't provide you with any solutions, it's up to you to figure out how to add these features.
Challenges
Challenge 1: Find a way to make the Enemy Ships move back and forth on screen.
Challenge 2: Restrict how frequently the player can fire the cannon, either by setting a maximum for the number of bullets on screen or by limiting how quickly the player’s Ship can fire bullets.
Challenge 3: Make the Enemy Ships fire back at the Player.
Where do I go from here?
There's a whole lot more to Stencyl, and we encourage you to experiment on your own and read through the rest of Stencylpedia to find out how to import your own resources, create your own Behaviors, and enable Stencyl to help you create the games of your dreams.
Continue to Chapter 2
94 Comments
~~UPDATE 3.0~~
PROBLEM WHERE BULLETS STAY ON THE SCREEN WHEN THEY HIT EACH OTHER (challenge 3 completed)
Both Bullets and Enemy Bullets physics should be set as:
What kind of Actor Type? -Normal
Can Rotate? -No
Affected by Gravity? -Yes
You will need two different events to fix this problem. Here is the code for Bullets.
First event: Add Event > Collisions > Actor of Type
when Self hits a Enemy Bullets
kill Self
Next event: Add Event > Collisions > Type
1
when I try to publish the game and save to my PC it tells me its unable to export the SWF file to the requested location. I tried several locations.. it says it may be an incompatible sound file.. which tells me nothing..
0
Hi!
Thanks for the course. But I need help D:
When I try to play the published game, it opens in a all balck (or white sometimes) screen. What should I do?
Thank you in advance!
0
extension of previous comment, bullets work the same way as preventing the enemies from going off screen. go back to the dashboard, actors, and make a duplicate of the bullets, the actor itself, not just the code. you need to adjust a few things when doing this as well, because it (Stencyl) will think it is another player fired bullet until you tell it otherwise.
0
to keep the enemies from falling off the screen is easy, and already done for you. remember when you set the limits to keep the player ship on screen? just copy that section of code and paste it into your enemy ship movement code. that way, no matter how you set them to move, they are unable to fall off the screen. It helps me to save a lot of time to just have a totally non used actor for the games with separate blocks of complete code on it just for quick reference and easy pasting. Label them what they are, for this situation the block of code is called screen limit, and you have your own fast access library of completed code blocks.
0
I made the fire back feature with logic of shooting my self, but i use do every N seconds. And i got "TypeError: Error #1009: Cannot access a property or method of a null object reference." I think it apears when parent object(enemy ship) fires bullet at my ship, and when enemy bullet is on a screen, but parent object is already dead. Please help me to figure what the key of my problem, or help me with enemy shooting logic!
0
@linkisnotzelda: I had the same problem. Apparently, it means that the game will try to make a dead enemy shoot a bullet, but since the bullet needs to be created at the enemy's position, the game crashes, because dead enemies have no x/y position. To fix it, you need to make a condition so that the bullet will only be created if the enemy is alive. Even better, use the enemy's health as a condition: that way, you will not have an exploding enemy shooting at you.
0





