Simple color change not working


#1

Well, a good nights sleep seems to have helped - I figured out the issue - Seems that the Trigger Once condition was fouling things up - still don’t understand why it worked but only in a specific sequence, but removing all of the Trigger Once conditions seems to have helped.

I’m still interested to know if there is a better way of writing this logic. Any assistance would be greatly appreciated!.


Hey folks, I must be missing something, but this simple color change project isn’t working properly and it is driving me nuts.
What is is supposed to do:

  • display 3 colored blocks on the screen (red, green, blue)
  • user clicks on any block, that block turns black
  • if another block was already black, it is changed back to it’s original color
  • the order or sequence you click on the blocks is irrelevant

What IS happening:

  • First click after launch - any block clicked turns black
  • subsequent clicks after launch (click 2+)
    If you click on red it will always turn black
    If you click once on green, it will only turn black if the prior block clicked was blue (except for the first click after launch) - if you click 2x on green it will turn black
    If you click once on blue, it will never turn black (except for the first click after launch) - if you click 2x on blue it will turn black

I have added a text block and actions to show currentSelect and priorSelect values to try and understand why it is doing what it is doing, but the values say it should be working.
Before you say that the order of the events makes a difference, the original order was Red, Green, Blue. Changing the order to Blue, Green, Red made no difference.

Second question - is there a better way of handling the “what is is supposed to do” scenario?

I only been working with Gdevelop for about 8 hours so far and I like it, but little things like lack of a flow trace is making debugging difficult.

I put the project in a .ZIP on my website if you want to look at it.
project file

Thanks,
Art.


#2

hi
I’ll take a look, doesn’t seem complicate.
Well its done I don’t really now what do you want previousSelect, maybe for some bigger project but I didn’t use it.
Don’t know if this is what you want


#3

Thanks for your help @xisco - unfortunately, the solution you provided for resetting the other colors works fine if there are only a limited number of objects. I will eventually be creating a puzzle that has 20 pieces, so repeating the “unselect” for 19 objects, 20 times will be tedious and error prone. By tracking priorSelect, I know which piece needs to be “unselected”. Just need to get the kinks out of the logic as Gdevelop is different from prior applications I have programmed in.

Thanks
Art.


#4

ok, I will try to modify your code.
Done


The problem is that in GDvelop the order of events is very important, so you.
If there was a switch case like in C instruction (maybe there is something similar I don’t know) you wouldn’t have this problem.
You changed priorSel and then still tested its value after changing so you changed its value again.


#5

@xisco - thanks for the offer, but I think I have it working now. You were right about the setting of priorSel - I set the value too early, so when I moved it to the same level as the “if currentSel != priorSel” statement, things seemed to be working properly.

Gdevelop is missing a number of conventions I am used to having in a programming “language”, but hopefully, I will be able to work around them - just have to remember how we used to do things back in the days of FORTRAN…