[size=150:21p6rmdr]PART 2: CONTROLLING THE PLAYER
[/size:21p6rmdr]Download tutorial fileChanges from Part 1
[*:21p6rmdr]Scaled collision box to better represent the player[/*:m:21p6rmdr]
[*:21p6rmdr]Added enemy sprite to "character" event sheet[/*:m:21p6rmdr]
[*:21p6rmdr]Press 1 to spawn a new enemy[/*:m:21p6rmdr]
[*:21p6rmdr]Organization, made folders for each character[/*:m:21p6rmdr]
[*:21p6rmdr]Moved the code to hide "solids" layer into the "system" event sheet[/*:m:21p6rmdr][/list:o:21p6rmdr]New Player Variables:
[*:21p6rmdr]hbSpawner: used to spawn a hit box when it reaches a certain time[/*:m:21p6rmdr][/list:o:21p6rmdr]Global Variables:
[*:21p6rmdr]hitPause: used for the hit pause effect when you successfully attack an enemy[/*:m:21p6rmdr][/list:o:21p6rmdr]Layouts and Event Sheets
[*:21p6rmdr] FXnStuff Layout: For...effects...and stuff[/*:m:21p6rmdr]
[*:21p6rmdr] Enemy01 Event Sheet: This event sheet contains all of the enemy code[/*:m:21p6rmdr]
[*:21p6rmdr] System Event Sheet: This sheet is for global game systems. Stuff like controlling particle effects, hitpause, camera shake, debug, etc. [/*:m:21p6rmdr][/list:o:21p6rmdr]Hit Boxes
When you press an attack button, you spawn a hit box. This is the thing that collides with the enemy's mask or collision box to register a hit. Hit boxes store attack data like damage (how much to subtract from enemy health) or force (how much x and y translation). When the hit box collides with the enemy, the hit box is destroyed to prevent hitting multiple times. If you want multiple hits just keep spawning hit boxes like in the punch3 code of the "player" event sheet (Line 41 and 42). The "dir" variable shows its usefulness here as I can use it to scale the hit box width in the negative direction if the player is facing left. Variable "hbSpawner" is used under the animation controls section to create the hit box. I don't usually like to put anything but animation specific code under here, but I made an exception for the hit box code. It just fit neatly in there. Hit Pause
Hit pause is something most action games use to make attacks feel powerful. When an attack connects, there is a short pause in the game to freeze frame the action. The heavier the attack, the longer the pause. It also offers the player a split second to think about what they want to do next. Try longer hit pause timings for a more dramatic effect.Hit Effects
I like to make my own particle effect systems in Construct for VRAM optimization and greater control. It's more optimized for VRAM because you can use one sprite for different systems. You also get more control because each particle is an object. All code for the particle effect is in the "system" event sheet.
Again, if there are any questions or something needs to be explained more clearly please let me know and I'll update the post.