dop2000's Forum Posts

  • Loading using Browser object: (maybe I should try convert it to NWJS

    It's already done with NWJS, where do you see any browser actions?

    NWJS.ChosenPath = If I got this right: actually telling the NWJS object to use the Chosen Path to Saved the file (that stored in the SaveStateJSON)

    ChosenPath is the chosen path to some file, nothing else. It has nothing to do with SaveStateJSON yet. Even the file itself may not exist, it's just a string containing a path, like "C:\Temp\MyFile.alon"

    And then you can write something to this path, and the file MyFile.alon will be created and contain whatever you've written into it.

  • Have you tried opening the file with Notepad? Didn't it appear strange to you that the file size is 0 bytes?

    .

    Looks like SaveStateJSON is only valid for one tick, after that it's reset. So you need to change the order of events - when button is clicked, first show "Save as" dialog, then on dialog OK save the game, on save complete write the file.

  • I can keep explaining this but you won't understand since you're a programmer and these things are obvious to you

    But you do see how ChosenPath and Path both have the word "Path" in them? It's not some sacred programming knowledge, just a very basic observation :)

    What you have on your last screenshot looks correct.

    What errors are you getting? Is the file created? If you open it with Notepad, does it contain JSON data (bunch of brackets, tags and numbers)?

  • FYI, there is raycast addon:

    construct.net/en/forum/extending-construct-2/work-in-progress-addons-30/plugin-jcwtrace-raycast-112436

    Also, in Construct 3 you can cast rays with Line of Sight behavior.

  • You are right, it's weird that with Sine or any other behavior, even when the platform is moving fast, the character stays on the ground. While with Tween it's constantly jumping/falling.

    I made a small demo project:

    dropbox.com/s/ayri8cqeglg79ek/TweenPlatformBug.c3p

    I suggest you log a bug report.

  • split("\n") works the same way as tokencount(text,newline)

    It searches for new line character, which is not there. If you break the text into multiple lines manually (by pressing Enter), then you will be able count the number of lines with those functions.

  • Again, you don't need to be a programmer to figure out that ChosenPath expression should go into Path field, not into the Contents field!

    I give up....

    Path: NWJS.ChosenPath

    Contents: SaveStateJSON

    No quotes!

    Here is how everything works, in plain English:

    1. 1. You save the game
    2. 2. On save complete event you have SaveStateJSON expression which contains game data. You need to save it to a disk file.
    3. 3. You display "Save as" dialog
    4. 4. After user selected a file, you now have file name in NWJS.ChosenPath expression
    5. 5. Finally you have everything to write your data (SaveStateJSON) into the file (NWJS.ChosenPath)
  • You've almost figured everything out yourself.

    Move "Show save dialog" to event 240, and remove "Wait for previous action to complete".

    Now look at the "Write text" action. You need to write saved data SaveStateJSON into the file with filename NWJS.ChoosenPath

    What you are currently doing is you are writing chosen path into the file named "mysave". Why?

    It looks like you are trying different random things in hope that one of them will work, instead of taking a moment to read. I mean it's right there - Path, Contents. You don't need to be a programmer to know what path and contents is.

  • Did you really read the documentation? Because it explains everything.

    The result of Save dialog is the file name only, which will be in ChosenPath expression. Then you need to write to this file.

  • Yes, you need to publish, otherwise these expressions point to the directory where NWJS is installed.

  • If you want to continue showing "SAVING PROJECT FILE" message while the "Save as" dialog is on the screen, you have no other option but to switch from using "Browser invoke download" to "NWJS Show Save Dialog", and then "NWJS Write text file".

    You can find how to use it in the official documentation, or search the forum for tutorials, examples. It's not difficult.

    But I would just forget about it, and leave it as it is - invoke download and immediately unlock the UI in the same event.

    .

    By the way, you should send the message to be shown in Text_Panel_CPU_Is_Busy in function parameter, and set text inside the function.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You don't really need to continue blocking UI when saving files. There will be a modal "Save as" dialog open, which will prevent users from doing anything else. So I think you can remove event 229, and in event 234 remove "wait for previous event to complete"

    .

    You can use NWJS actions and events to save files, if you want more control. You can find answers to your questions in the official documentation :)

    .

    Also, by TextBox I meant Text Input object.

  • "On saved dialog cancelled" may be triggered after "NWJS Show Save dialog" action. You are using "Browser invoke download" to save files, that's why it's not triggered.

    Boolean flag is needed for checks in your various events.

    If you add any opaque layer or background above everything in your project, it will not block mouse clicks, they will still go through to objects underneath. You need to use TextBox (or another Form Control object), only they block mouse events.

  • Tokencount(text,newline) counts the number of line breaks, it will not work here.

    I don't think it's possible to correctly count the number of lines in text object. You can use Text.TextHeight property to get the text height in pixels. And then divide this number by an average height of each line, say 30px. You'll get an estimate number of lines which may not be very accurate if you have a lot of text. Also, different browsers render the text slightly differently, so the results may vary.

    With SpriteFont you can calculate line height and the number of lines precisely.

  • If you need rigid connections, you have to make triangles. For example:

    Red lines represent joints.

    And of course you should try to minimize the number of objects with joints.

    Maybe build the line with just a few big sections using long invisible sprites with Physics. And draw a smooth visible line with small visible dots, pinned to Physics sprites.