How to link buttons to actions

Hi everyone,
I’m very new to Wick Editor and and am using V 1.19. I have not attempted scripting anything since the days of GW Basic and MS Dos and am struggling a bit.
I have made a wick file to try understanding the use of multiple buttons via mouseclick.
Ideally:-
Mouseclick a button for it to start a frame sequence from a given frame number then return to the start of the game (not to exit the game). Repeat this, clicking on a different button for it to start another frame sequence from another specific frame number further along the timeline then jump back to the start again.
Ultimately I hope for the cumulative clicks on different buttons to drive a counter, with some buttons set to increase the count and others set to reduce it.

I have an animated clip following the mouse. using this.x = mouseX; this.y = mouseY When the button is clicked this.x != mouseX; this.y != mouseY; is intended to break the link between clip and mouse but I had to create a duplicate clip for the tweening action I want.
The intention is for the clip character to jump from whichever button is clicked to bottom right of the screen. Currently it always reads the first frame sequence on the timeline, whichever button is clicked.

Now I’ve typed this up it looks like a big ask. I intended to attach my trial wick file, but cannot see how. Sorry if I’m asking for something previously covered in the forum but I couldn’t find relevant info.
Thanks
BAA1

Hello @BAA1 welcome to the forums!

Yes that is possible.

Instead of this.x = mouse.x …
Why not make it so the “character” coordinations will be the buttons coordinates

On the button MouseClick script: character.x = this.x; character.y = this.x

I didn’t really understand that much but if you have any questions feel free to ask more!

Thanks CosmicKnight1 for taking your time to reply.
I realise trying to unravel what is happening from my description must be nigh impossible.
I have now spotted the upload button in the forum reply so have uploaded V3 and V4 of my test scripting,
In V4 I inserted your script for buttons 1 and 2 but this freezes the program when either button is clicked, preventing progress to the gotoAndPlay statement.
This is just a quick mockup.
I am hoping to make a number of buttons the starting point for different tweened actions.

V3 is where I got to after posting my help request.
The mouse character stays with the mouse all the time. This is OK. When a button is clicked a copy, not a clone, is made to tween from the button to bottom left of the screen using the gotoAndPlay statement.

I know I’m getting something wrong in my use of gotoAndPlay
button1 script under Mouseclick is gotoAndPlay(2-23);
button2 script under Mouseclick is gotoAndPlay(25-46)
Animation layers for the tweened characters are:-
Layer man1 and Layer man2 and each have the above related mouseclick script in frame 1.

Regerdless of which button is clicked the program plays frames 2 to 23, yet when I drag the pointer along frames (25-46) the specified action works and the character jumps from button2 as intended.

If checking this is asking too much of your time I do understand.

Sprouts Game 3.wick (189.9 KB) Sprouts Game 4.wick (189.9 KB)
Thanks again.

1 Like

For game 3
instead of doing gotoAndPlay(2-23), just do gotoAndPlay(2); and for the other button just do gotoAndPlay(25);

gotoAndPlay function only accepts one integer number from 1 to timeline length. If you put 2-23, js is doing a subtraction first and the puts the result into the gotoAndPlay function… so 2-23 = -21; since -21 is less than one, wick editor process that number as frame 1.

Thanks Jovanny,
I sorted the other problems, I will now address that.

1 Like

Thanks to your help I sorted the problem.

Your suggestion locked each character to a button location, as you suggested, but kept it there. However this led me to examine how I was trying to use the buttons.

I rewrote a test wick file from scratch but purely using the buttons to control timeline segments. This worked fine. By trying each element as a stand alone wick file before including it in the test file it clarified my thinking. My trial has Start and End buttons plus two buttons linked to different timeline segments, each containing gif animations.
Including gif files was interesting. Gifs saved from previous wick projects would not load as assets. However saved as MP4 files then processed as gifs using online service Ezgif the new gifs loaded.
Also one of the gif video sequences is longer than the number of frames I allocated for it on the timeline. I discovered that each click of the linked button would run segments of the whole video in sequence.
By extending the number of frames available to the gif the length of the segments played on each click was extendable frame by frame to the point where the complete video would play. I’ve no current ideas to use this but where a pogram requires sequential access to video clips, such as different levels in a game, referencing the one button to activate a gif with equal frame length scenes could save a lot of scripting.

The test Wick file is attached below, if it’s of interest.

All the best.
BAA1https://1drv.ms/u/s!AsxediqGRlwXhAh9h3eScUVOZLcG

1 Like

Hahah no problem! Glad you figured it out.