Function params, triggers and calls

Get help using Construct 2

Post » Sat Sep 26, 2015 6:43 am

@nimos100 That's not quite how it works. 4 players can be:

4 on gamepad 0 on keyboard
3 on gamepad 1 on keyboard
2 on gamepad 2 on keyboard
1 on gamepad 3 on keyboard
0 on gamepad 4 on keyboard

That said, it is not always practical, but it's a possibility.

Then the other plus is that you can assign Player to Movement functions. Imagine a title screen where you choose a character. Some characters move up and down, others move left and right. With my setup you can tell how a character moves with the Controls function and then assign a Player (e.g. gamepad index) to it. So with one controller you can be either one character.

@ramones thank you very much for clearing this out for me. Now that I know I can't use Trigger once in functions, I'll look for another way to simulate the "On Pressed" condition.

I've something in mind and I'll test it tomorrow to see if it works and post it here.
Ba-dum Tsss!
B
11
S
2
G
1
Posts: 45
Reputation: 757

Post » Sun Sep 27, 2015 4:44 pm

Alright, I figured it out!

Since "Trigger once" is actually triggered every tick, that means that it is incapable of memorizing whether a button has been pressed or not. However an array can remember that :)

So I've created another array called "Active" that is pretty much the same as "Controls":

"Controls"
- A cell is 0 by default
- When a button is pressed it becomes 1
- When it's released the cell becomes 0 again

"Active"
- A cell is 0 by default
- When a button is pressed it becomes 1
- When it's released the cell becomes 0 again

Now I can actually compare both:
Controls - Active - State
0 - 0 - no button pressed (default)
1 - 0 - button is pressed, but could also be down
1 - 1 - button is definitely down (pressed will not trigger again)
0 - 1 - button is released (pressed has been reset)

So the script goes like this:
Code: Select all
if(controls[0,0] != 0) {
    if(active[0,0] == 0) {
        // do something like move left
        active[0,0] = 1;
    }
} else {
    active[0,0] = 0;
}


An example image:
Image

Now I'm 95% positive I can merge "Controls" and "Active" arrays into one and shove the logic directly into the "Controls" function itself which will simplify things by a whole lot.
Ba-dum Tsss!
B
11
S
2
G
1
Posts: 45
Reputation: 757

Previous

Return to How do I....?

Who is online

Users browsing this forum: Bootfit, OBLIVION, worm1 and 27 guests