6/18/2023 0 Comments Stencyl bar when test game![]() Create a new scene called “Win” I am going to use my HUD actor to show the win feedback, but you could add anything here. Now we need a win state, or in the case of Stencyl a win scene. In the CardFlip behavior I added some iterators to those variables I set “Sets Matched” to zero to start and since I only have two sets on the stage, “Sets Remaining” is set to 2. In the Card Table Scene’s Events set the variables to initialize when the scene is created. We are going to use the two variables we made earlier. We still need a win state for this to make it somewhat of a game. Follow the guide above if you need any help.ĭon’t forget to set the group for the new cards to “Cards”, and to name the animations front and backĭrag out sets onto the page. Now go ahead and create as many other card actors as you like, applying the behavior as you go. Apply it to the Ace of Spades via the behavior tab. Now we can apply this behavior to all the cards we want. I had to place the pasted code into the event block.Then go back to the Ace of Spades actor and disable the On Actor Event I am going to copy the code from the Ace of Spades actor and paste it into this behavior so we can use that code over and over on all the cards Back on the dashboard I create a new actor behavior using the Design Mode and Actor Behavior radios. To do that, we are going to create a custom actor behavior. Next we are going to apply the code to another card and see if it works. It could be said that all programing is best done iteratively like this. Did everything come together as planned? Building onto what we haveĪs I said before, we don’t need to create a masterpiece from the start. This is a good place to stop and test to see if you’ve messed anything up. Now, following the pseudo-code from the beginning of this tutorial we create an event behavior in the Ace of Spades When two cards that are not the same are flipped, all of the cards need to flip back, so we use groups to tell the program that. We also need to create a group for our cards. Sets Matched - Number - to display the score in the HUD Sets Remaining - Number - to keep track of the remaining sets Cards Flipped - List - to keep track of which cards are flipped over I need to make some game attributes to control the game flow. TLDR: Send user feedback to a text variable, draw the text variable in an actor. I have covered creating a super easy HUD in another post. We also need some feedback because reading the log viewer in flash isn’t really ideal. We know we are going to be applying this behavior to a card later, so while building the card behavior we need to keep that in mind and use the available attributes to keep any actions as generic as possible. Test your game! When you click a card, does it show the face of the card? If not, go back and make that happen before moving on. When the card is pressed we switch to the front animation So we will add the following actions to the events tab of the Ace of Spades actor. Then I brought 2 Ace of Spades actors out onto the stage.Īt it’s most simplest, we need to flip a card when the player clicks on it. We need a scene for this all to take place. Back should be the first animation (the one with the star), as it will be the one shown when we start. I name them, front and back, and make sure they don’t loop. I then add the images of the front and back of the Ace of Spades as animations. In Stencyl I create a new game called “Card Flip Tutorial”Īnd then create a new actor called “Ace of Spades” You will need a front and back of a playing card to start, and later, more fronts of the cards. ![]() So we will make a list of the cards that have been flipped.įor the purpose of this tutorial, I found some open source playing card images and converted them to jpegs. Stencyl uses game attributes as global variables, or values that are available to all the actors in the game. else if there are no other cards flipped over, record the type of card flipped so the comparison can be made in the above logicįrom the above pseudo-code we know we are going to have to keep track of the cards that are flipped. else if there is another card flipped over and the two cards do not have the same value, it's not a match, flip both cards back over Remove both cards, add a point to the score if there is another card flipped over that has the same value, it's a match. We are going to build a memory card flipping game using Stencyl 3.0 so lets get the pseudo-code out of the way first, or at least a part of it. It’s the most important part of the game, making it secondary might mean it is not well polished. In the case of Games I like to build from the main game mechanic outward. You are so much less likely to run into an issue. As someone who has been coding for many years, I find that building things with small iterations is best. If you are good at coding you might go ahead and do things without testing them and you might not have any issues.
0 Comments
Leave a Reply. |