Tips & tricks compilation - Share your personal favorites!

Discussion and feedback on Construct 2

Post » Fri Jun 05, 2015 3:04 pm

I think a lot of us are really great at using C2, but I'm sure many people have interesting tricks and tips they use during coding that can make our lives easier. Let's share some of those tips!

    Set up a textbox with debug information, such as your character's speed, vectors, acceleration, etc. Put it on a 0,0 parallax UI layer so you can see it at all times.

    On player death, set up a textbox to appear saying "killed by X." This has helped me SO many times because it points you directly to the event on the event sheet that is related to the player death. Useful when there are traps in your levels.

    The "MoveTo" plugin lets you smoothly move any sprite over a distance or toward an object without changing its position every tick (like you would do without the plugin).

    Make your playable character's stats variables. For example, make his speed "PlayerMaxSpeed," then define this variable in the event sheet. If you ever need to change his speed or let the player upgrade, you won't have to go edit the event sheet line by line. Good for gravity, max speed, acceleration, etc.

    An easy pause screen event: On press (pause button) -> set time scale = 1-timescale. If it is 1, it'll go to 0 (paused). If it's 0 (paused) it'll go back to 1!
B
22
S
5
G
1
Posts: 41
Reputation: 1,730

Post » Wed Jun 10, 2015 11:55 am

Easy 1 event toggler for when you want two different values that can be tested for.
[Condition (for example when pressing a key)] -> Set variable (the variable that you want to toggle) to variable - variable*2.
This will make it so that the event toggles the value between negative and positive.
B
6
S
2
G
2
Posts: 33
Reputation: 891

Post » Wed Jun 10, 2015 3:11 pm

Nifl wrote:Easy 1 event toggler for when you want two different values that can be tested for.
[Condition (for example when pressing a key)] -> Set variable (the variable that you want to toggle) to variable - variable*2.
This will make it so that the event toggles the value between negative and positive.



I do it by using variable*-1 so it always toggles between 1 and -1 for instance (for True/False). There was a better way that used 0 and 1 but I always forget how to do it..
B
122
S
42
G
40
Posts: 846
Reputation: 27,994

Post » Wed Jun 10, 2015 3:13 pm

@andreyin set variable to (variable+1)%2 ?
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Wed Jun 10, 2015 5:36 pm

@Andreyin You're probably thinking of var = var - 1. Toggles between 0 and -1.

A "trick" I like to pair with this is ternary operators / conditionals. Not the best example but they work like:

Set bullet angle of motion to Player.Dir = 0 ? 0 : 180

I suggest tracking down @Tulamide 's old tips and tricks thread. Had some pretty cool stuff in there. I suppose it was more of a "cool things you can do with math" thread though lol. Could definitely use more of those around here!
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685

Post » Wed Jun 10, 2015 5:55 pm

Well, it's little thing, but I like to add these as globals:

TRUE = 1
FALSE = 0
NULL_ID = -1

Sometimes I use 0 and 1 instead, but I like these for conditions like:

PlayerActive = TRUE

or, more usefully, calling a function, where I want to make it clear I'm passing a boolean val:

Func SetFoobar(TRUE, 100, 200, 180)
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,187

Post » Wed Jun 10, 2015 6:04 pm

Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,187

Post » Wed Jun 10, 2015 6:19 pm

@Tokinsom

I think that @Aphrodite got it right, but I really suck at operators so I keep forgetting what do they do exactly.

Also checking that old thread now, damn those are handy.
B
122
S
42
G
40
Posts: 846
Reputation: 27,994

Post » Thu Jun 11, 2015 5:55 am

not sure if trick but definitely a performance booster.

if you have pathfinding on your enemies and your obstacles move on screen -
adding each 0.2s regenerate obstacle map (to family of objects) works pretty nifty and fast, instead of each tick. or per each enemy. on default settings 0.2s seems to have no effect of enemies hitting into sprites that are obstacles, tried 0.5s but then they do hit.
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
41
S
14
G
12
Posts: 623
Reputation: 9,359

Post » Thu Jun 11, 2015 8:49 am

Do yourself a favour. Always name your layers. Dont just stick with the default name when you create a layer. It makes them far easier to refer to later in development.
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180


Return to Construct 2 General

Who is online

Users browsing this forum: HenryPK, tarek2 and 3 guests