fisholith's Forum Posts

  • Hey there Syazanie Amirin,

    Below is a bit of overview, and my thoughts on the two methods, in case it helps.

    Local storage

    Local storage lets you save and load specific data, and importantly, when you load data, you can use it whenever an however you want.

    Save system

    The save system saves a complete snapshot of the entire game state. Loading a state is kind of like time-traveling back to exactly how things were when the state was saved.

    Save system exemption

    There are lots of situations where you may not want the entire game restored that way, because some information about progress you may want to keep. (e.g. Unlockable items.) To avoid losing that information, you can exempt certain objects from being captured by the save system using the "No Save" behavior.

    Hybrid

    But if this information is saved by the save system, then how do you avoid losing it when you close the game? Well, this is another situation where local storage can help. Anything data that should persist between play sessions, that isn't getting saved by the native save system can be manually saved to local storage.

    Save system quirks

    Finally, the native save system is quite good, but there's one quirk that can cause problems. It may not save absolutely everything exactly as it was, and this can cause some problems when restoring. The only example of this I've found is that you can selectively disable collisions between different Physics objects, but when restoring from a save state, that disabled-collision-state information is not restored.

    I wrote up a bug report for this issue at the link below.

    The game I'm working on uses Physics objects with some disabled collisions, as a result I don't use the save system at all, and rely exclusively on local storage.

    This is just my experience with the two methods though. Hope this helps.

  • Hey there WieBrei,

    I'm not sure, but if reinstalling C2 didn't fix it, then it seems like the problem may lie in some external resource that C2 tries to invoke when loading certain projects.

    Even so, it may still be triggered by some aspect or content of a project. For instance, if C2 is trying to load something specific to a certain object, and some part of that process prompts C2 to do something that results in a crash.

    Questions

    Are there any projects that will sometimes work and sometimes crash, or is it that specific projects consistently always work or always crash?

    Can you post a list of the projects that do open and the ones that don't?

    Multiplayer Chat - example capx

    You mentioned that the Multiplayer Chat example capx crashes.

    I made a list of all the plugins it uses:

    [Plugin: Name]

    Browser : Browser

    TextBox: ChatLog

    TextBox: ChatTextBox

    Function: Function

    Button: JoinButton

    Keyboard: Keyboard

    Text: Label

    Multiplayer: Multiplayer

    TextBox: NameTextBox

    List: PeerList

    Button: SendButton

    Text: Title

    Button: ViewTutorial

    The plugins:

    Browser

    Button (Form control)

    Function

    Keyboard

    List (Form control)

    Multiplayer

    Text

    TextBox (Form control)

    IT may be that "form controls" are somehow causing a problem. They are not HTML canvas elements, unlike most other graphical pluggins.

    Other aspects of this example:

    • It doesn't use families.
    • It does use groups, and nested groups, and nested events.
    • In properties, it's physics engine is set to "Box2D web" (the other project you said sucessfully openened used "Box2D asm.js" instead). Perhapse C2 does something involving the selected physics library, when it loads a project.

    Web GL - example capx

    [Plugin: Name]

    Sprite: BackgroundSprite

    Sprite: CogSprite

    Mouse: Mouse

    Text: Text

    The plugins:

    Mouse

    Sprite

    Text

  • I just discovered something pretty weird about C2's Particles object.

    In some strangely specific circumstances, the particle images actually will rotate.

    Expected behavior:

    The native C2 Particles object, for rendering optimization reasons, doesn't provide rotation options for the particle image.

    So, if you rotate a layer, say 45 degrees, (e.g. to simulate camera rotation), with a Particles object on it, the particle images will not rotate with the layer, and will instead stay oriented upright to the monitor.

    Weird behavior:

    However, there is a weird case where they will rotate with the layer.

    If the Particles image dimensions are 256 x 256, and the Particles Size property is 256, and the layout is scaled up by any factor greater than 4 (e.g. 4.001), then the particle images will rotate with the layer, as if they were inheriting their orientation from it.

    This is the only case I've ever seen that causes Particle images to rotate.

    I suspect it may have something to do with the particle sprites being large enough that they can't entirely fit in the renderable canvas area. e.g. Using 512 x 512 images and a layout scale of 2.01 will also cause the layer-inherited rotation.

    Example Capx:

    https://www.dropbox.com/s/72r6sibcytwem ... .capx?dl=1

    In case anyone is interested. :)

    Steps to reproduce:

    Objects:

    Create a native C2 Particle object.

    Set it's image dimensions to 256 x 256.

    Draw a vertical bar for the image.

    Set the Particles "Size" property to 256.

    Create a simple tiles grid backdrop. (So it will be easier to see the layer's rotated orientation.)

    Add Mouse object. (Just need to use the buttons for interaction.)

    Events:

    At start of layout, Set layer angle to 45 degrees.

    On Click Left, Set layout scale to 4.1

    On Click Right, Set layout scale to 3.9

    Now preview the game, and click the left and right mouse buttons to see the particles alternate between un-rotated, and rotated.

    Any idea what's going on here?

  • Hey Ashley, just curious if you got a chance to take a look at this.

    I know you have a ton going on, so no worries either way.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You're the best, Ashley!

    That fixed it!

    Somehow the registry data representing the dialog's layout got a bit messed.

    I must have done something weird. I don't recall anything, but it might have been something like stretching it to max height, getting sidetracked, and then hot-key moving the whole application to a monitor with a smaller vertical resolution while the dialog was still open.

    I assume the dialog's data is somewhere in,

    HKEY_CURRENT_USER\Software\Scirra\Construct2\Dialogs

    I checked the registry before doing the restore, and exported the Quick Bar data, so I could restore my customizations after the reset.

    HKEY_CURRENT_USER\Software\Scirra\Construct2\BCGWorkspace

    (Quick Bar and other workspace stuff as far as I know.)

    After resetting, everything was restored to defaults, including the Quick Bar, and I was able to set that back to my custom configuration just by running the exported .reg file.

    I updated the topic name to indicate that it's solved, and wrote up instructions for resetting the dialogs, and optionally backing up the Quick Bar first.

    Thanks again.

  • Hey Ashley, I don't want to take up your time with something that may only affect one person, but if you have any quick thoughts or suggestions, I'm all ears. If not, no worries, I'll keep looking into it. If I figure out a solution I'll post back here.

  • [SOLVED]

    Fixing glitched dialogs

    Note: The solution will reset your Quick Bar (toolbar just under the ribbon).

    If you haven't customized the Quick Bar then just do the 2 steps below.

    If you want to be able to restore your Quick Bar customizations, see the "Backing up your Quick Bar" section first (farther below).

    1. From the main menu bar, choose File, then click the "Preferences" button.

    2. On the "General" tab, at the bottom click the "Reset dialogs" button.

    Done.

    Backing up your Quick Bar

    There are two ways to do this,

    Screenshots: Take screenshots of the items, and later restore them by hand.

    RegEdit: Use the windows Registry editor to export the relevant data, and later restore by clicking the exported ".reg" file.

    Screenshots

    1. Right click the Ribbon or Quick Bar, and choose "Customize Quick Access Toolbar..."

    2. Use Alt + Printscreen to capture the items in the list. (You may need to scroll.)

    3. Paste or save the resulting image(s) somewhere handy.

    4. Do the steps in the "Fixing glitched dialogs" section above, and then restore your customizations by recreating them.

    Done.

    RegEdit

    Important! Do NOT use this method unless you're comfortable editing the windows registry.

    Messing up the registry by accident can prevent your computer from booting.

    1: Open RegEdit, and navigate to:

    HKEY_CURRENT_USER\Software\Scirra\Construct2\BCGWorkspace

    2: Right click the "BCGWorkspace" folder icon, choose "Export", and save the .reg file to your desktop.

    3: Do the steps in the "Fixing glitched dialogs" section above, and then restore your customizations by double-clicking the exported .reg file.

    Done.

    [Original issue]

    Both the Condition and Action object browser windows suddenly became glitched.

    Any help or suggestions would be appreciated.

    Image & Description

    The browser area extends to the window-top, under the Info and Search elements.

    The bottom buttons are displaced upwards off the bottom panel area, and don't respond to clicks.

    I can't think of anything I've changed or done that would cause this.

    I couldn't find anyone else with this issue though, so it seems like it's probably something weird on my end.

    I'm at a loss for what's going on, and C2 is currently not really usable in this state.

    Ruled out

    It doesn't seem to affect any other windows in C2, nor any other windows in any other program.

    Hadn't updated C2, or graphics drivers.

    Hadn't updated windows as far as I know.

    Tried

    I've tried installing an older version of C2 that worked, but the problem persisted.

    Tried re-installing the current version of C2, but no luck.

    Both installs applied the built-in uninstall step of the installer, but I don't know how extensive that uninstall job is or what it affects.

    Perhaps there are elements I could manually uninstall that would resolve this.

    OS and Service Pack

    Win7 x64 - Pro

    SP1

    Construct 2 Version ID

    Release 247 (64- bit) checked

    Built at 13:33:48 on Sep 21 2017

    Release Notes

  • Problem Description

    Overview

    The native C2 save/load system appears to forget the "disabled collisions" state of Physics objects.

    After loading, all Physics collisions are enabled regardless of prior state.

    Details

    The Physics behavior has an option to "Disable Collisions" between objects, on an object-by-object basis.

    I'll refer to the data structure that stores that inter-object collision info, as the "collision relationships list".

    e.g. Given SpriteA, SpriteB, and SpriteC, you could disable collisions between only SpriteA and SpriteC.

    All other collision combinations would still occur normally.

    When using the native C2 save/load system, if you save, and then load, the Physics behavior's "collision relationships list" state is not restored.

    After loading, all collision relationships are set to enabled.

    Attach a Capx

    https://www.dropbox.com/s/jpvaro62rvj8t81/fi_demo_Physics_DisabledCollisionsForgottenOnSaveLoad.capx?dl=1

    Description of Capx

    Image of the capx.

    The capx shows a real-time interactive demo of the problem.

    There's text in the capx to explain steps to execute and what to look for.

    The capx shows two physics enabled sprite objects, a static (Immovable) Orange box, and a moving Blue box.

    The moving blue box is attracted to the Red "X" which drags it back and forth in a horizontal sine motion.

    On layout start, collisions between the blue mover box and orange static box are disabled.

    This allows the blue mover box to pass through the static orange box without colliding.

    At the bottom of the canvas are 5 buttons.

    • Save: Save game state via native C2 save/load system.
    • Load: Load game state via native C2 save/load system.
    • Set no-hit: Disables collisions between Mover & Static.
    • Restart: Restarts layout.
    • Toggle text: Show/Hide text.

    Steps to Reproduce Bug

    Run the capx.

    • Observe the blue box passing through the orange box without colliding. This is due to the event: On start, disable collisions between those objects.
    • Click the "Save" button, to save the game via C2's native save/load system.
    • Click the "Load" button, to load the last save state.
    • Observe the blue box now collides with the orange box. The disabled collision state has not been restored.

    You can optionally experiment a little further:

    • Click the "Set no-hit" button to re-disable collisions.
    • Observe, the boxes no longer collide.
    • Retry clicking the "Save" and then "Load" buttons.
    • The boxes now collide again.

    Observed Result

    The Physics behavior's "collision relationships list" is not restored after loading the game state, and so the boxes begin colliding with each other.

    Expected Result

    The "collision relationships list" is restored after loading the game state, the disabled collision status between the boxes is likewise restored. and so the boxes pass through each other without colliding.

    Affected Browsers

    • NW.js: YES
    • Chrome: YES
    • FireFox: YES
    • Opera: YES
    • Iron: YES
    • Internet Explorer: YES

    Operating System and Service Pack

    Win7 x64 - Pro

    SP1

    Construct 2 Version ID

    Release 247 (64- bit) checked

    Built at 13:33:48 on Sep 21 2017

    Release Notes

  • Hey evillair, <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    Just an interesting note...

    It might be worth looking at the "Delaunay Triangulation".

    It's probably overkill for what you're building, and it specifically produces a mesh of triangles which is a bit stricter than what you require, but it has some nice properties.

    The Delaunay Triangulation does a good job of connecting nearby points without creating sliver triangles.

    It's the dual graph of the voronoi graph.

    If you're familiar with voronoi patterns, for the Delaunay Triangulation, you get the center points of the voronoi cells, and create links between points in bordering cells.

    Boris Delaunay, who came up with this Triangulation solution, worked on this back in the 30s. He also climbed mountains, and somewhere there's one named after him. I don't know much else about him, so I can only assume he lived as hard as he mathed.

    Here's a visual animation of a Delaunay Triangulation algorithm working on a set of random points.

    Subscribe to Construct videos now
  • Q1: When I save data via the Local Storage plugin, is it stored in a human readable format?

    For example, if I save the current level the player is on via Local Storage,

    say key "level" = value "3",

    is there now a file somewhere that, you can open in a text editor, and see a line like "level = 3"?

    Q2: Regarding human readability, Is there a difference between using Local Storage from a browser, vs a desktop (NW.js) platform.

    I've found what I think is the location Local Storage data would go (for NW.js at least),

    "%AppData%\Local\<GameName>\Cache",

    but what I see is a bunch of hashilly-named files most of which are 1KB.

    None of it looks human readable, but I don't know if I'm looking in the right place.

    I'm just going by a comment Ashley made in another post.

    Any help is appreciated. :)

  • That is super helpful rexrainbow, thanks!

    Looking at the pin behavior is a great suggestion.

    I'm happy to hear there's an "afterLoad()" function, because I was wondering how to set up connections to things that might not be loaded yet.

  • What's the best way to serialize an array of references to C2 object instances?

    Overview

    I have a third-party behavior, that holds an array of references to C2 object instances. (These references are gotten from the SOL.)

    This array is part of the behavior's internal state, with "this.references" being declared in the onCreate() function.

    To get this behavior to cooperate with C2's native Save/Load state feature, I need to be able to save and load the behavior's internal state, using the saveToJSON() and loadFromJSON() functions.

    The saveToJSON() returns an object to be serialized via JSON.stringify(), I think.

    I think that JSON.stringify(), if given an array of C2 object refs, will try to serialize the entirety of each C2 object referenced. This causes a "Circular structure error", and isn't what I need to do anyway.

    I don't want to serialize C2 objects, as all I need to save are the references to those objects.

    Maybe I can get the UIDs of the referenced objects, and save those.

    Then I can rebuild the correct references upon loading by looking up object instances by the saved UIDs.

    Does anyone have advice on serializing an array of C2 object instances?

    Any thoughts or sugestions are welcome.

    Specific case

    Finally, the specific behavior I'm trying to extend is Azis's "Store Reference" behavior:

    I've already found and fixed some other problems with this behavior, but I just recently noticed it has no Save/Load support built in.

    It's a nice idea for a behavior, but I'm just about at the point of replacing it with native UID-based events, since I know I won't have to fix anything else in the future if I just stick to event sheets.

  • Thanks for letting me know ,

    I fixed the links.

    This is the updated bundle.

    Themes Bundle - Fisholith Themes v2.zip

    It also includes some notes on choosing and setting C2 "Styles", which are different from "Themes".

    Example of choosing a Style

    Styles - what are they?

    Styles vs Themes

    "Styles" are different from "Themes".

    Themes mainly set colors for event sheets. (You can edit them with my Theme Editor, or in C2's properties.)

    Styles set the colors for the overall user interface, like scrollbars, and panels. (Style colors aren't editable.)

    Choosing a Style

    1. On the ribbon, choose the "View" tab.

    2. Click the "Style" button (with the brush icon), and from the drop menu, choose a style.

    (Note: The default style is found under "Office styles" > "Office 2010 Silver".)

    The 3 notable Styles

    • Office 2010 Silver - This is the default theme for C2.
    • Visual studio 2012 Dark - Good for dark themes.
    • Carbon - Not as dark as 2012 Dark, but it's the only other Style with a dark background.

    Tip: If you use a dark Theme, then also change the Style to "Visual studio 2012 Dark",

    so you don't have bright white panels right beside the dark event sheet.

    Style Limitations

    C2 comes with some pre-built Styles to choose from, but you can't edit their colors.

    This is because Styles are developed by Microsoft, and embedded across a mixture of DLLs and system files.

    The 3 important styles

    Dark Styles are important because they can be paired with dark Themes.

    All styles for comparison

  • After exporting via NW.js, what is the propper way to rename the executable files in the Linux & OSX folders, so they show the name of my game instead of just "nw"?

    For example, I know that in the exported Windows folders (win32 & win64), I can rename the "nw.exe" to "My Game.exe".

    What would I do in the Linux & OSX folders to equivalently replace the default export name with the actual name of my game?

    For example, in the Linux64 folder, if I change the name of the "nw" file to "My Game", would that work, or would it break something that's expecting the file to be named "nw"?

    Any insight or suggestions are welcome.

  • Thanks for letting me know redfoc,

    I just updated the link, so it should work now.