Simple Platform Tutorial Part 3

2

Attached Files

The following files have been attached to this tutorial:

.capx

complete-3.capx

Download now 2.73 MB

Stats

3,069 visits, 4,604 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 30 Dec, 2013. Last updated 19 Feb, 2019

Now I do request for forgiveness for my blunder in part two. Because I fail to remember introducing 2 blocks and never explain about that.

These 2 block are break_block and hit_coin now we need these two because if we don’t then you will be breaking COIN BLOCK and Knockoutblock. Furthermore collision detecting will not work the way we want.

Player touching nearest block like break-block and coin-block will do the trick and also it will be destroyed, therefore if you hit that coin-block again it will not create coin again and again. Set these two blocks to invisible state. Now another thing to add is fade behaviour to COIN and set fade time out to 4. If we don’t then coin will be spinning around on screen forever and we do not want to do that do we?

Now we bring in ADVERSARY and make it move and what not. Our enemy is little intelligent and also so thick as well.

Create sprite and Import 3 frames of Spider and remember we add animation for player left, right. Well this time I will show you different way to manipulate directions. Now this spider animation we call it walk and speed set to 8.

Now add one more animation under walk and Import dead spider.

PLEASE NOTE THAT ALL SPIDER ANIMATION FRAME SET ORIGIN BOTTOM CENTER OR WHEN SPIDER IS DEAD YOU FIND THAT IT WILL HANG IN MIDDLE

Create Instance variable and name it walkdir and it should string set value as right.

Now add behaviour PLATFORM and FADE. And set spider speed to 40 and default control set to NO. And fade is not ACTIVE at start. Fade out time set 4

Now we create another sprite and name it spiderwall, set size about 16 x 48 set it to

INVISIABLE.

NOW FOR CODE

Enter above in your events and run it should work fine.

Now we should add collision between spider and hero (player) below is code

Now we have to add spider Hill as objective to enter cave. Create sprite and name it spiderhill.

Now create another sprite and name it spiderwall and set behaviour to solid and set invisible.

Place your spiderhill like this

Now whenever you standing on top of spiderhill and press down ARROW you will enter the CAVE.

Now to come out of CAVE we will add same spiderhill and spiderwall (JUST COPY IT) AND Paste it somewhere further down say 1296 x 325. This is the place when we emerge from CAVE.

This concludes collision between SPIDER AND PLAYER Entering CAVE.

Now we create our second screen for player to fall down in and call it CAVE.

Once we finish designing our cave it should look like this

Not that first-class is it, well you could do better.

Create block for wall and set behaviour to solid. Something like this and design your CAVE.

Create another sprite and call it EXIT and set size about 16 x 64.

Go back to your main screen and COPY BOTH PLAYER AND PLAYERSHADOW to do this just use your mouse to press left button just above your player and playershadow and drag it over to bottom of right and you should have both selected. Now press Ctrl and C and copy it or click right mouse button and from dialog box click COPY.

Go back to your CAVE and paste it above your CAVE. Now you must be wondering why put him above and not inside CAVE?

Reason for this is it will look real that our player is falling down the cave and not just appear in CAVE. Once you play it, it will become clear to you. Once you design the CAVE as above CLONE COIN and name it as bonuscoin. Place the bonuscoin as you like and finish the CAVE design.

Now code for the CAVE create GOBLE VARIABLE and name it CAVE and Value to 0 (ZERO)

Code for pressing down ARROW TO ENTER CAVE

Now whenever you stand on Spiderhill and press down arrow you will be transported to cave

Once you are in cave start collecting coins and EXIT when you EXIT CAVE you should be appearing somewhere else and not in same place.

When you collide with EXIT in cave we need code for that. Click on Cave events:

HERE PRESS RIGHT MOUSE BUTTON AND CLICK ON INCLUDE EVENT SHEET

Include the main game events which is controlling player and so on. Why we are including this because we do not need to add any player movement and so forth. Trust me it will work.

As you can see above I have Include: Gamemain events

This should work fine now it’s time to add scores

Lock other layers and just unlock HUD. Here we create SCORE textbox. Add textbox to top left hand Conner and name it Score. In the textbox text just adds Score as text.

Now in Blocks where it says playershadow on collision with coin add this code

Now you must be wondering I did not add code like EVERY TICK UPDATE SCORE well I think you do not need to use that just update your score when you require it. Wasting CPU time by every tick. Now this should work well in your game. Now at the end of your lay out add tree like so

Add door as sown in picture and add 1 more frame and add other door too. Set animation frame to 0 and no loop.

Now go to your Main event sheet and create Global variable and name it Level set to 1 ONE. We are on level 1 so when we go to Level two game engines will know we are on Level 2.

Now I am not going to design Level 2 but, I am just going to Duplicate Level 1. As for you be brave and design Level 2 if you wish.

Now we are going to check our player collision with door in our main event sheet.

Now if you do not add wait statement you won’t see your Door entrance which is frame 1 in door animation.

Test out your game, should work fine

Now this concludes our tutorial, adding sound and so forth is your challenge. Be brave and courageous. I have done best as I could now it's up to you to add sounds and make it better.

Good luck and God Bless

.CAPX

complete-3.capx

Download now 2.73 MB
  • 0 Comments

Want to leave a comment? Login or Register an account!