konterball's Forum Posts

  • Thanks!

  • Hi there,

    In the Addon SDK v1, the runtime had the "IsInWorker()" function as well as the "IsPreview()" function. Now it seems that there is only "IsInWorker()" left.

    How can I check via the SDK v2 whether the game is in the preview?

    Thank you :)

  • Ashley Uhhh. I found out that my addon causes the localStorage to be null. How is that possible? Any ideas?

    I'm using Developer Mode -> Add dev addon. Could this cause it?

  • Ashley Yes, I thought so too, but nope:

    The tip with IStorage sounds good. I'll try it out. Many thanks!

    Could you tell me how to access it in domSide.js? That would be great :)

    iRuntime is avaiable. Could i use it for it?

  • Hi there,

    I'm currently working on an addon that uses, among other things, loading and saving functions from an external SDK.

    The problem is that loading and saving doesn't work in the preview (correct behavior), but only in the corresponding environment. All good!

    BUT: I would therefore like to use a fallback storage in this case. Unfortunately, the usual suspects are all null.

    Even including an external library (hello localForage) doesn't help, because the drivers that are actually supported don't work either and supports() returns false for them.

    What other fallback options do I have?

    Thanks :)

  • Ashley Yes, of course I understand that. I just don't want the project to run locally.

    I use an SDK that unfortunately complains if any JS code is called before it is initialized. And that is exactly the snippet that causes this issue. Therefore has to be removed manually.

  • Is it possible to export a game as an HTML5 version in such a way that the following script is not automatically added to the index.html, so that you don't have to remove it manually afterwards?

    <script>
    if (location.protocol.substr(0, 4) === "file")
    {
    	alert("Web exports won't work until you upload them. (When running on the file: protocol, browsers block many features from working for security reasons.)");
    }
    </script>
    

    Thanks in advance!

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • To use "await", you simply have to precede the function with "async". Like this:

    async _GetValue() {
    	const value = await asyncFunction();
    	return value;
    });
    

    The second question is still open.

  • Hi there,

    I have two questions:

    1.) How can I handle asynchronous functions in domeSide.js? At the moment it is very complicated:

    Example:

    Is there an easier way? I couldn't use await.

    this.AddRuntimeMessageHandlers([
    	["get-value", () => this._GetValue()]
    ]);
    
    _GetValue() {
    	asyncFunction().then(value => {
    		this.PostToRuntime("set-value", value);
    	});
    }
    

    I need two MessageHandlers. Is there an easier way? I couldn't use await.

    What obviously doesn't work:

    _GetValue() {
    	const value = await asyncFunction();
    	return value;
    });
    
    _GetValue() {
    	asyncFunction().then(value => {
    		return value;
    	});
    }
    

    2.)

    It looks like you can use _postToDOMAsync in conditions. Is it correct that this doesn't work with expressions?

    Thank you very much

  • Hi there,

    I want to create my own addon and have downloaded the sample. Developer Mode is activated.

    Now I get the following error message: addon.json specifies id "MyCustomID", but expected id "MyCompany_SingleGlobal" (see screenshot).

    BUT: If I now set MyCompany_SingleGlobal as the ID again, I get the error message the other way round:

    addon.json specifies id "MyCompany_SingleGlobal", but expected id "MyCustomID". Well.... what?!?

    I would now like to uninstall the add-on, BUT ?safe-mode doesn't work. The screenshot was taken on editor.construct.net

    Why doesn't safe mode work?

    The documentation says: "To remove this addon, you can clear your browser storage." What exactly do I have to clear? I don't want to delete my entire storage, just Construct-specific entries (I use Chrome).

    Please help :)

    Thanks in advance.

  • WackyToaster Thanks for your engagement :)

    Well, for "Letterbox Scale" it seems to work. At least for the top in landscape mode. I'm afraid that i need it for "Scale outer". There it behaves completely different, but maybe there is only a little change necessary?

    Addendum: window.innerHeight and window.innerWidth are different from all values that can be determined via Construct. Would you have to use this to calculate some ratio in order to then be able to calculate the width and height in proportion?

    Actually you would need a scaling value, but it always seems to be 1...

    But maybe I'm completely on the wrong track.

  • WackyToaster Thank you for your quick and very detailed answer :)

    An iFrame is not possible. I depend on the environment in which the game is to be shown afterwards. The navigation bar is placed on the game as an overlay by this environment, so I don't think an extra layer makes sense, correct? If the navigation were in-game, then yes. But only space should be created and the UI elements should be pushed further down (or to the right) in order to avoid the overlap mentioned.

    I have now created a sprite "Spacer" (1x1) and positioned it in the top left corner via "Anchor" (thanks for the confirmation). In theory it now behaves as it should, but I still have problems with the size. Full width and height works now, but how do I ensure a constant height/width of 100 pixels?

    If I simply use "Set size" with the value 100, then the value changes proportionally to the window size:

    If I make the window smaller, this value also becomes smaller. How can I make 100px fixed?

    Thanks :)

  • Hi,

    the goal/problem is this: I need free space around the game (top, right, bottom and left) to display banner ads and/or a navigation bar. Unfortunately, these elements need to be on top of (over) the game, so I need to make sure these don't overlap any game UI elements.

    For the bottom and right side it's pretty easy: I just reduce window.innerHeight and window.innerWidth by x pixels after export and the game thinks it's smaller and adjusts accordingly. No problem!

    For the top and left side this works in some frameworks with marginTop and marginLeft (so moving the canvas further down or to the right). But not in Construct 3. This is where a pointer issue occurs. When you click on a button (as an example), the new (visual) position of the button is not taken into account, but the original one. Not good :)

    Questions:

    1.) Is there a way to solve this pointer issue after exporting? So to let the subsequently set values of marginLeft and marginTop flow into other variables?

    2.) If this has to be solved in the game. What would be the most elegant method?

    I tried adding a spacer. In landscape it should be on the left side (width of x pixels, full height) and in portrait mode at the top (full width, with x pixels height).

    Is there a behavior that could make this easier for me?

    I tried this manually:

    On the one hand, I have problems setting the full width/height, and on the other hand, the value for height or width (e.g. 100px) seems to get smaller or larger when resizing. In short, it doesn't seem to work front or back.

    My goal? If I have a spacer, I could position the UI element based on this spacer.

    Basically, this seems to be a very complicated and time-consuming method. Isn't there an easier way?

    Thanks a million in advance!

  • Hi,

    I would like to know how the IndexedDB name is generated for the projects (e.g. "c3-localstorage-qtd9m4wizxb").

    Does this happen at the very beginning when the project is created and can therefore no longer be changed?

    I would have guessed that this was somehow related to the project ID, but apparently not.

    The problem I currently have is that if I reskin a game and, in extreme cases, only exchange assets, they still share the same database. Or what else do I have to change so that this doesn't happen anymore?

    I changed the project name, ID and even the version. When exporting, however, the "qtd9m4wizxb" was still to be found in the data.json.

    Thanks in advance :)

  • Ok, my question isn't just about "below the canvas", it's about all sides:

    How can I manage to shrink the canvas so that I have a black area where I could place ad banners without the risk of them covering game UI elements.

    Below the game you can do this for a 60px area like this: window.innerHeight = window.innerHeight - 60;

    Of course, this is only intended as an example and is not a good idea to override innerHeight.

    However, Construct's resize function uses window.innerHeight.

    The easiest way would be to wrap a container around the canvas. Reserve a space there and the canvas will only take up the space that is still available. Is something like this possible?

    Or is there another approach that makes more sense? In worst case, I would also be satisfied with the bottom and the right side only :)

    Thanks in advance!