I have been asking by some of you how to use touch control in platform game? Well for my work I do not use Construct 2, only for tutorials for friends and Construct 2 forum. Construct 2 manual and Ashley has explain this in detail but it give the impression that no one reads manual and ask this question on forum. Well must not make any protest, argument, or carry-on about it as we are here to help.
Create new project and name it as you like. I have used new retro style project because then I am lazy and idle thinking well Ashley done all the work why should I do any. In this retro project Ashley has provide you with:
Therefore you don’t have to add these.
1. Set windows size to 640 x 480
2. Set layout size same 640 x 480
Create 4 layers and name it
4. Touch control
On background use colour of your choice, for map use mine or use your own. Player uses mine or creates your own and for TOUCH control creates 3 Sprites and names them as follows:
• Left touch
• Right touch
Create Text to place it on 3 sprites, these sprite is just green box size 32 x 32 and placed at bottom of layer on Touch control layer. Design your platform screen like below and the behaviour to solid.
Open your Event Editor and enter code below. Keep nice and orderly all you have to do is use GROUPS like I do. Also it will also be helpful for beginner to insert Local Variable easily as well. I am using Local Variables to show you how we can make player do jump high or make it look like scaling wall.
Enter this code below:
What I have instruct Construct 2 to do at start is our green sprite box is bright and also we don’t want to see that therefore I have set OPACITY 5, then I have created GROUP call Touch left, and then inserted code there:
What we saying is player is in Touch control touching Left Touch green sprite then move player Left, set animation left, set it to mirrored and to see our Text box we just update our text and same goes for our Right touch but, not mirrored.
First enter line Touch is touching Jump_Touch Player Simulate pressing Jump now high light whole line and PRESS V this should open Local Variable box and enter what is in code, also please note rest of these lines are in sub event. If you have entered the code correctly your project will work as it should. I have provided CAPX for this demo.
God bless you all