How do i make a selector select things

What Wick Editor Version are you using?
1.19.3

Describe the Problem
im trying to get my character select to work but it aint workin

What have you tried so far?
old code from the old files

Do you have a Wick Editor File that we can see? Optional*

game4-3-2023_13-14-31.wick (2.0 MB)

i need some help guys

anyone?
10

@Hamzah_Al_Ani can you help me out?

sure thing :+1:

So, you’d first of all want to create two variables (in the default script of the frame) set to the selected characters. By default, let’s set the chosen characters are “none”

// default script, first frame
project.p1='none';
project.p2='none';

Next, select each character box and turn it into a clip.


Make sure to rename each clip based on the character’s name (box, rod, yellow, rei, alex, sam).

Next, create a function for the select coins inside of the default script of the first frame.
This function will be used to detect which character each select coin is touching.

project.selectCoin=function(a){
    var options=[rei,alex,sam,yellow,box,rod]; // array of all options
    var r='none'; // default value is "none"
    options.forEach(function(b){ // for every option...
        if(a.hits(b)) // if touching coin
            r=b.identifier; // change value to the name of the option
    });
    return r; // return the results
};

Since the coins are moved by keyboard, inside of the “keyreleased” script for SP1 coin, add this script:

project.p1=project.selectCoin(this);

Do the same for the SP1_copy clip, but switch “project.p1” with “project.p2”

This way, project.p1 and project.p2 will both be set based on which character box each selecting coin is touching (by “selecting coin” I mean SP1 and SP2, idk if selecting coins is their name but I’ll call them that for now).

Here’s an example file: _game4-6-2023_18-36-32.wick (2.0 MB)
I added in a text clip to show you what project.p1 and project.p2 variables are set to.

Using this, you can know what characters the users have selected.
I hope this is what you needed.

1 Like

YES YESNYES THANK YOU THANK YOU THANK YOU this is what I needed

1 Like