Changing Effects with Sliders + Remember the values?

0 favourites
  • 10 posts
From the Asset Store
Try to remember the sequence of moving pumpkins. Reproduce it according to your memory.
  • Hi All,

    I've created these:

    - Dragable Panel with sliders to change HSL / Brightness / Contrast

    - Family of instances called: "Created_Objects"

    I'm trying to do these tasks but I got confused during the process:

    Whenever I click one of the instances, it is "Selected" (I've created an instance variable for the Family).

    1. The Sliders should control ONLY that specific "Selected" instance.

    2. Clicking on ANY instance should "Remember" their current sliders values (if I changed any)

    3. Click outside the Panel should change position (out of the layout) instead of destroy it, so the Panel always come back when I click on any instance.

    I'm not sure how to explain what I'm trying to do exactly so if you don't understand my explanation steps above let me know and I will try to explain it better.

    I've attached the messy C3 project that I'm doing my tests on so you can actually see what I've described above (minus the steps I didn't solve yet) so feel free to have a look:

    Download C3 Project

    It's the first time I'm messing around with effects and sliders and I'm still excited but a bit confused with how to connect them with the instances and control each one as I tried to describe above.

    Thanks ahead for any help, tips, and visual-screenshots or example to help me explore and learn from it!

    Tagged:

  • I dont have license, so I used sprites instead of families:

    Hope, you got the idea.

  • Clicking on ANY instance should "Remember" their current sliders values (if I changed any)

    You can set effect parameters, but you can't read them back from the sprite. So you need to store them somewhere in instance variables.

    When an instance is clicked, set sliders to values in these instance variables.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I gave it a try - as usual, there are quite a few tricky things to get right!

    thanks to rokstars322, I was able to edit your sample by deleting one of the effects from the Created_Objects family - since I don't have a C3 license yet either. All the code is there, so you can just add the Contrast effect back in to make it work...

    your disabled code was not working because you were checking for a click on Created_Objects, Selecting the object, then the next event was undoing it (because the mouse click was still true, and now there was a selected object to unselect).

    so I re-structured that whole section... (I also deleted the fullscreen code because it was running every tick and making my screen flicker)

    Having a Control Panel adds a whole new level of complexity and new problems to the logic of an object family. If the panel is over an object, any click on the panel may also register as a click on any objects below. In your case, that would cause your code to mysteriously change selected objects without you knowing why. AND if there isn't an object under the panel, then the code would think you are trying to un-select objects! (which would also cause the panel to disappear!)

    the solution I have used to fix these issues in the past is to have an object be part of the family and use it as a shield. So, I made a Panel_Shield sprite, set it to be invisible, and made it the same size as the panel, and pinned it to the panel. When ever the panel is brought on the screen, the panel_shield must be moved to the top of the layer because if there are any objects above it, you will have trouble. (or keep it on the UI layer - I had to delete layers because of free version limitations).

    the panel_shield is given a unique "ObjectType" so that we know to ignore clicks on it. It is also important to always use "Pick Top Instance" when doing any mouse button events so that the shield properly blocks clicks from objects we didn't mean to click.

    rokstars322 showed updating the Created_Objects when the slider "On Changed" trigger fired. that only updates the value when the slider is released. So, I followed your code where the value is updated every tick so the user can instantly see the effect.

    and, like Dop said, you need to store the values in instance variables in the family...

    https://www.rieperts.com/games/forum/effects.c3p

  • Thanks Everyone! for helping in this learning experience, I appreciate your time and patience with me.

    So I just downloaded the version AllanR made so I can look at the code, the comments and see if I can follow it.

    OFF TOPIC:

    I would never find out that the fullscreen have issues because in my PC (desktop build) it's not flickering, so THANK YOU for sharing this with me! I've added "Trigger Once" to the boolean events and now it's fine after I checked with the console log, no more endless loop. :)

    .

    BACK TO TOPIC:

    As I'm reading the comments and also the detailed explanation of the code it helps a lot but I must be honest, I couldn't solve this by myself based on my current experience. some things that you guys are having a quick solution in seconds or HOW to actually code it inside C3 so thanks for sharing your experience with me!

    I'll try to play with the code a bit and see if I can replicate something like that in my bigger project which is going to be challenging for sure, I do have some theoretical questions before I even start because I'm always curious:

    In my bigger project, I use "GUI" layer to put Panels, buttons, sliders, anything that is ABOVE everything else mostly the actual instances.

    One thing I noticed about the set position of the Panel when clicking on instances.

    1 - Is there a simple solution: if the instance is REALLY close to one of the edges?

    is it simple as: "If Panel position is OUT of layout -/+ Panel.width (for x) and -/+ Panel.height (for y) I have never tried these things and it's very interesting because when the panel is not active I guess

    2 - Is the system saving going to grow REALLY HUGE in size if I'll have MANY instances on the screen with the extra effect values changes per each that needs to be saved, or since it's just "numeric values" the size will barely grow and I don't need to worry about it?

    I will try some things while re-creating the basic code idea to my project so please try to understand me for asking questions mostly because out curiosity: if I even "THINK" in the correct way or my solution may be a total stupid and waste of time compare to YOUR way of thinking. this is how I can learn and understand things better as I go via discussion and not just jumping to code without thinking about it first.

    I'm sorry about my bad English and I want to thank you all once again for your patience with me, it is not something I take for granted! all of you are amazing for helping me learn new things, THANK YOU!

  • Is the system saving going to grow REALLY HUGE in size if I'll have MANY instances on the screen with the extra effect values changes per each that needs to be saved

    Why don't you simply test this? And why do you think other people should know this? :)

    Run the project, create 10-50-100-200 instances, see how big the save size is (you can check it in Browser log). Write it down.

    Add a bunch of instance variables, repeat the test, compare values.

  • your english is very good. I have helped people on the forums for years because it is a great way to learn and try out different solutions to interesting problems.

    "1 - Is there a simple solution: if the instance is REALLY close to one of the edges?"

    is there ever really a simple solution? :) you know the width and height of the panel, so yes, you can use those values to tell if it is on the screen or not. The tick is where to move it so as to not cover up the object you are trying to modify... I tested to see if "Bound to Layout" would work, but there is no way to disable that when you want to hide the panel. So that means you would have to destroy it and recreate it every time. So, it is probably easier to just calculate where to put it...

    2 - save size

    I think you will be ok, but you will want to test that out at some point. I suspect that you could add a couple thousand objects before size will become a problem. but that is just a guess.

  • > Is the system saving going to grow REALLY HUGE in size if I'll have MANY instances on the screen with the extra effect values changes per each that needs to be saved

    Why don't you simply test this? And why do you think other people should know this? :)

    I just explained above why I'm asking before I even test and I did say that I will test.

    I think other users are much more experience and may already have a clue about this because it's not specific to my project, if C3 extra values in general may change the size of a file or not really unlike sprites size for example.

    As I explained above, I ask questions before I test for better understanding and learning a better approach and workflow in order to improve, it doesn't mean I won't test things. Learning from others and their experience may not just direct me but also open new, better, efficient ways than my basic-thinking, this is why I'm asking. :)

    Run the project, create 10-50-100-200 instances, see how big the save size is (you can check it in Browser log). Write it down.

    Add a bunch of instance variables, repeat the test, compare values.

    Thanks! this is VERY helpful I'm so happy that you told me about the console and the browser log, now I use it A LOT!

    I tested to see if "Bound to Layout" would work, but there is no way to disable that when you want to hide the panel. So that means you would have to destroy it and recreate it every time.

    I'm not sure if it's efficient, but I really like to put other panels and all the instances in their own dedicated Layouts because it is cleaner and more organized.

    What I don't know is if Create/Destroy is slower, taking more memory or just not that critical at all even for older machines, I cannot test on other machines for now so I'm trying my best to avoid anything that may be a wrong way to do things. it make sense that just changing position to something will be faster but I still like the idea of Create/Destroy anything that is reuse a lot of times on the current layout but again... what do I know. :)

    I suspect that you could add a couple thousand objects before size will become a problem. but that is just a guess.

    That's very helpful in my opinion, yes! even for a rough guess it's much better than having no idea how it works in general, there will be testing! and a lot of them hehe :)

    Thanks once again you guys are truly amazing!

  • Alon

    It just feels like you are afraid of trying new things. You prefer to ask on the forum "what would happen if I do this or that", instead of simply testing yourself.

    Worst case scenario - something will not work, undo the changes and move on.

    .

    About the save size - have you tried viewing your ".alon" files? Create one object instance, save to .alon file. Then rename the file to .json and open it - you can upload it to any online JSON viewer website, or simply open with Firefox. You will see that there is nothing scary there, just some information about your layout, layers and object instances. You can actually find object's instance variables and their values, and will see how much space each variable is using.

    This can help you to get better understanding of how things work in Construct. Besides, you may find something in the file which will help you to optimize and decrease the save size, for example some objects that don't need to be saved.

  • It just feels like you are afraid of trying new things. You prefer to ask on the forum "what would happen if I do this or that", instead of simply testing yourself.

    I guarantee to you that I'm not afraid of trying new things, This is how I became a professional animator, by trying and tasting new things and I'm still learning new things every day, but I also make sure to teach my way-of-thinking to the animators on our studio, some of them have only 3-5 years of experience in animation and they're afraid to ask, I always encourage them to ask in order to learn new techniques that will sure be more efficient and not just speed-up their workflow but also give them ANOTHER ways to accomplish their sessions.

    Animation isn't the best comparison, it was just an example. :)

    In programming if I don't KNOW what to test or what is the most efficient way to even test something, or even some basic programming terms, you must ask in order to learn, there are many things I try myself and then I get stuck... if you'll read the very first post here for example, you'll see that I tried until I got stuck, these blocks are not simple to guess how or what to do for a none-programmer.

    I just think that you don't agree with my way of asking in order to learn new things even before trying to get a much better attitude, but it is fine and I respect your opinion. :)

    About the save size - have you tried viewing your ".alon" files? Create one object instance, save to .alon file. Then rename the file to .json and open it - you can upload it to any online JSON viewer website, or simply open with Firefox.

    This can help you to get better understanding of how things work in Construct. Besides, you may find something in the file which will help you to optimize and decrease the save size, for example some objects that don't need to be saved.

    That's something I would NEVER KNOW if you wouldn't tell me about, what you just explained is TOTALLY NEW TO ME, and it's pure gold which seems like a very helpful tool!

    Now I'm super curious about googling a JSON Viewer and examine my .alon files!

    it seems like a very good way to find hidden useless things that I can cleanup THANK YOU SO MUCH! I'm learning so much and I must say that this is inspiring to me.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)