Drawing Canvas Object - Can I do this? How? is it Safe?

0 favourites
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi All,

    I'm messing around with the Drawing Canvas Object and I'm not sure about some "rules" of what can I do or not, or if I shouldn't if it's not recommended or anything so I have some questions:

    1 - Can I use more than one Drawing Canvas Object on my project? (on different layers)

    2 - If the above is safe (crashes/errors) will it be too heavy for older machines? or it's fine?

    3 - Will users with NO dedicated GPU cards (older machines) are still able to use my software with the Drawing Canvas Object? or they will have some issues?

    4 - Using the NWjs, can I IMPORT .PNG image file to specific Drawing Canvas Object? if so, can you share an example code or screenshot please? it will be very helpful!

    I have few more questions about the Drawing Canvas Object but if anyone can help make the above questions clear first I'll appreciate it, and once again, any C3 example or screenshot for example will be very helpful for me to learn how it's done.

    Thanks ahead!

  • 1 - Of course, just try it and you should see it works

    2 - It depends entirely what you do with it. Probably

    3 - Yes, all features still work without a GPU, just slower (software rendering)

    4 - You should be able to load it in to a Sprite, then paste the Sprite

  • Thanks for the answers Ashley! it looks like it's very useful for my project. I'm glad it will also be supported by older machines that's great!

    I would like to let my users the option to import .PNG file that will cover the Drawing Canvas Obj (Sprite that will paste) so they can also clear the canvas if they regret, or import something else later.

    I've already done something like that thanks to dop2000's awesome help (with the URI), but I get lots of scary red warnings on the console (F12) when importing which are total gibberish to me and I'm afraid it will cause issues later.

    Any chance for how to do #4 ?

    a sample project file or screenshot that I can replicate to my own project?

    Since you know it best I bet you can help with the most efficient code for this, I'm aware that you're extremely busy but if possible, it will be amazing!

    Thanks ahead :)

  • I've already done something like that thanks to dop2000's awesome help (with the URI), but I get lots of scary red warnings on the console (F12) when importing which are total gibberish to me and I'm afraid it will cause issues later.

    What warnings? Please always include the exact text of any such errors, it's impossible to comment without it.

    Any chance for how to do #4 ?

    Load the PNG in to a Binary Data object, then use the Sprite action to load an image from a URL, and use the Binary Data object's URL.

  • You already know how to load an image into a sprite, and you already know how to paste sprite onto a canvas. Why do you need help with this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You already know how to load an image into a sprite, and you already know how to paste sprite onto a canvas. Why do you need help with this?

    That's True, but it's because of the scary RED warnings I mentioned:

    These warning only appears when I import so I wonder about a more ways if there are any...?

    Ashley dop2000 Thanks ahead :)

  • I'm guessing that message is from your Saving/Loading system or from Undo. It probably has nothing to do with loading an image into sprite. Or maybe you are using "Sprite Set from JSON" instead of "Load image from url".

    I'm just encouraging you to experiment and try solving problems yourself, instead of posting here about every little issue you encounter. You'll learn much quicker.

  • I'm guessing that message is from your Saving/Loading system or from Undo. It probably has nothing to do with loading an image into sprite. Or maybe you are using "Sprite Set from JSON" instead of "Load image from url".

    I'm just encouraging you to experiment and try solving problems yourself, instead of posting here about every little problem you encounter. You'll learn much quicker.

    You may not believe me but I'm not just jumping on every single issue I have, I'm solving some minor issues (that are for my basic brain-level) one-by-one but some walls I have no clue how to handle or can't see where the issues like these warnings.. total gibberish for me to even understand where to start looking... what I'm saying is "every little problem" for advanced programmer like yourself is usually much bigger for newbies like myself.

    ANYWAYS... Back to TOPIC:

    As always, listening to your advice as you give me the direction what to check in a specific issue instead of me keep guessing for days, as I disabled the "SAVE LOAD - SYSTEM" (group) the scary red warning were gone.

    BTW - Disabling the UNDO/REDO SYSTEM won't change a thing, the the RED warning appears, only the SAVE LOAD - SYSTEM (if it helps).

    That's my Current version of the code, what cause it? it's not that "Load image from url" but maybe something inside? I have no clue! it must be something STUPID that I did or ruined... again :|

    The all Ajax/JSON is still something I have no idea how or what to do with, it's nothing I understand and it seems very complicated how it works inside the parameters with all these options of data and what not.

    My IMPORT - Load PNG (group):

    Thanks ahead for any help! :)

  • Well, you are doing it again :) You disabled the Save/Load system and the error message went away. Great, but why stop at this and ask for a solution on the forum? Why not try to find what's causing this error yourself? You already know how to do it - add debug messages to all events which you think are involved, run the project in debug mode, open console, press the button, see what's happening, try to figure out the sequence of events and soon you will wind the fix. Troubleshoot! Nobody can do this better than you because nobody knows the project as well as you do. (I'm almost sure it's something to do with Undo flags not properly set or cleared)

    About JSON - you don't need to understand its structure to use it. JSON (from saved state) is just a string of data, containing information about all objects in your project. When you load from JSON, all objects are recreated from that data, that's it.

  • Thanks for the advice, I appreciate it as always and it's not taking for granted. :)

    Every direction, hint, way helps me to learn and I will keep investigating this and hopefully I'll find something! (I really hope so)

  • UPDATE:

    After a VERY LUCKY first guess, once I disabled the last action on line 157

    I get no more RED warnings...

    OK, so far it's nice that I got rid of it, I even played around with the software to HOPE! that I didn't damage anything else by disabling this action. (I will keep testing of course)

    The thing is, I have no idea what this action suppose to do, it's from the early version suggested code so can you please explain:

    - What's this action supposed to do?

    - Is it safe to remove it from line 157?

    - Or it will damage something I didn't ran into yet?

    Thanks ahead, and sorry for the mess... the original post was to learn about the limits of Drawing Canvas Object and not focus on bugs, but yeah... things happens.

    UPDATE 2:

    NEVERMIND THAT... can't load and save LOL!

    I'll Keep on the guessing journey :)

  • It does exactly what it says - loads game state from the file you selected in "Open dialog".

  • If you're just trying to get something working I'd strongly advise: create a new project and figure it out with the fewest objects and events. Then move it over to your main project.

    As it is it sounds like you are constantly running in to conflicts with the rest of your project, which sounds like it includes hundreds of events. It will make your life harder, and it makes it confusing to explain and difficult for others to help.

  • I also have a feeling that you have two "On open dialog OK" events - one for loading image files, and another for loading save files. They are both triggering and causing havoc. Add some kind of flag to distinguish them, or activate/deactivate event groups, or make one universal event, where process files differently based on file extension.

  • If you're just trying to get something working I'd strongly advise: create a new project and figure it out with the fewest objects and events. Then move it over to your main project.

    That's always a good advice, I've done this for minor features I test and now it's a bit more complex to make new project with all the UNDO/REDO and EXPORT/IMPORT systems and the variables etc.. because it's about 80% of my project but there is no doubt! it is a good way to get cleaner project. if I won't be able to solve anything from the mess I have I'll probably have to do that...

    I also have a feeling that you have two "On open dialog OK" events - one for loading image files, and another for loading save files. They are both triggering and causing havoc. Add some kind of flag to distinguish them, or make one universal event, where process files differently based on file extension.

    Yes, I do have 2 "On open dialog OK" but they're separated by different buttons, under different groups (as shown on the images above) I guess that's not enough! :(

    I mean, I don't see anything strange from loading/saving/exporting on the log, no more than 1 line after I click "OK" from loading or saving at the time.

    But if you're saying it could be an issue, I should go for the most efficient and SAFE way indeed!

    I'm not sure how to do one universal event to separate the files and confused about how to deal with a boolean.. maybe something like when click: "Btn_Load" or "Btn_Save" or "Btn_Export" to toggle the boolean, still confusing to me how this should actually help separating them or solve this.

    But WAIT! it's getting even better:

    I also found out that I cannot UNDO imported images, but I'm not even trying to think about it now as I have to get rid of the SCARY RED warning message first.

    Yeah.. my brain is exploding at the moment I'm going nuts because I thought I finally got some progress killed the early bugs! (panic mode = on)

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