Sam Dimanche's Forum Posts

  • try this code from Stack Overflow

    I'm not familiar with javascript so I can't implement this, but thanks for the suggestion !

    Maybe System->Is on platform to detect if HTML website or NW.js

    I think it works ! If I'm previewing on NW.js, the condition "Is on platform NW.js" is true, but if I'm previewing on Firefox "Is on platform HTML5 website" is the one that's true. That seems to be exactly what I was looking for !

    Thanks a lot to you both !

  • Hi friends

    I'd like to create a save system that distinguishes whether the player is playing online on a browser (example : on itch.io) or in "desktop mode" (using the nw.exe).

    • Player is online ==> I'm saving using the LocalStorage Plugin
    • Player is on desktop-mode ==> I'm saving using the NWjs Plugin to write a simple text file.

    The goal is to protect the desktop player from losing all his save data after using Ccleaner or another tool of this kind. I find this more comforting. I just save strings of text, so nothing big.

    My question is : how do I detect if the player is playing on a web-browser or in desktop-mode ?

    I thought I could use the Browser plugin to get data on the player's session (example : Browser.Name, Brower.Platform, etc...) but it doesn't seem to work as I'd like it to. The data doesn't look useful in this case. For example, running the game in preview mode on Firefox and on NWjs, Browser.Name is always "Netscape" and Browser.Platform "Win32".

    Can someone kindly tell me where to look for ? =)

    Thanks a bunch !

  • Hey Mekonbekon ! Thanks for your reasonable advice. I think you're right : if it's not broken, don't fix it. Nobody ever criticized the definition, so why bother ? ^^

    I think I just needed to hear that to go on. See you

  • It works for Instance Variables yes. At startup you always have to recover the local storage data and store it somewhere in your game : you can store it in an instance variable just as in a global variable

  • Hi there,

    I have a question regarding the Window Size of a project. Foolishly I only found about this property after months of using construct 2. My project is well advanced but now I'm concerned about the fact I'm still using the "original" window size of 854x480 (with Letterbox Scale when fullscreen).

    To add to the complexity, at some point in the project (months ago already) I decided to zoom out a bit, thus game layers are scaled at 0.75 in the eventsheets on start of layout. UI layers (parallax 0,0) are not scaled however.

    I'd never noticed this property before, nor felt the use for it, since everything works just fine even when I'm in full screen mode...

    I'm considering changing the Window Size to a more common 1600x900 now, but it would imply a LOT of work to resize ALL my sprites. Would it really be useful ?

    1200x675 (still 16:9 proportions) could also be possible, because game layers would be less affected (854x480 with a 0.75 scale are already an artificial 1138x640) so I'd mainly have to resize UI elements.

    I have 3 choices then.

    • Keep the original 854x480 size and keep scaling back some layers to 0.75
    • Move to 1600x900 window size (I'll have to rework everything)
    • Move to 1200x678 window size (I'll just have to rework the UI)

    Tell me what do you think I should do, and what difficulties I'd be facing if I keep my actual window size. Thanks for reading !

  • You could also cascade the Else statements like this maybe ? <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

    mediafire.com

  • Hey Plinkie, thanks for your answer

    Yes it works like that of course, but that doesn't explain why it doesn't work the other way around. It's more a question of principle at this point.

    Plus I shared a very simplified Capx, in my actual project it is easier to check for the variable and then check for the input. It worked perfectly with a gamepad and when I tried to duplicate the events to handle the keyboard it started bugging.

    I could change everything of course, but I don't want to do it before I know why it wasn't working in the first place ^^

    Blackhornet >> Thanks for your answer. I understand what you say, but I've coded small games before with lots of buried triggers (keyboard and gamepad related) and it worked just fine :/

    Now that I'm looking at one of my old projects, I realise I never used any trigger of the sort underneath an "Else" statement though, so everything seems to come from there...

  • I there,

    I've encountered a problem using an "Else" expression.

    Basically I have :

    [quote:2hrbkc1c]Global Number variable = "1"

    IF (variable = 1)

    --> Key "Enter" is pressed --> Call Function Addtodebug "AAA"

    ELSE

    --> Key "Enter" is pressed --> Call Function Addtodebug "BBB"

    Problem is : if I press Enter... I'll see "AAA BBB" in the debug text box oO

    I've been using construct 2 for a while now, and this really surprises me. Why doesn't the "Else" expression filter the keyboard input there ?

    Also it seems to bypass everything else in the "Else" subevents because if I add this :

    [quote:2hrbkc1c]IF (variable = 1)

    --> Key "Enter" is pressed --> Call Function Addtodebug "AAA"

    ELSE Call Function Addtodebug "Random Text"

    --> Key "Enter" is pressed --> Call Function Addtodebug "BBB"

    If I press Enter... I still see "AAA BBB" in the debug text box. The "Random Text" part never appears.

    And to put the nail in the coffin : everything works PERFECTLY if I'm using a Gamepad and Gamepad inputs. Thus :

    [quote:2hrbkc1c]IF (variable = 1)

    --> On gamepad 0 Button A is pressed --> Call Function Addtodebug "AAA"

    ELSE

    --> On gamepad 0 Button A is pressed --> Call Function Addtodebug "BBB"

    We see "AAA" in the debug box as expected. The Else statement works just fine.

    Does this mean all inputs are not considered equal ? How are keyboard inputs different from gamepad ones ?

    A simplified CAPX illustrating this conondrum can be downloaded here : mediafire.com

    Thanks in advance for your help, I lost a few hours isolating this problem and I'm scratching my head as to why it doesn't work <img src="{SMILIES_PATH}/icon_redface.gif" alt=":oops:" title="Embarrassed" />

  • Ok, thanks for your explanation you two

    As long as it's not messing the calculations, it's ok. I'll use the rounding trick if I want a figure to appear in a debug log from now on.

    Cheers and thanks again

  • I'm converting a number into a string, sure, but that doesn't explain why Cos(270°) becomes this weird number when it's not alone. 0 converted into a string should still be "0", right ?

    Cos(270°) should always be strictly equal to zero... unless I don't understand cosinuses well (which is a possibility).

  • What do you mean ?

    I can usually concatenate figures without problem

  • Hi there ! <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy" />

    I'm no big connoisseur in trigonometry but I had to dip into it a little in order to generate a laser for my Run N' Gun shooter. I've managed to have my laser working but I've been puzzled by one small inconsistency I can't explain...

    (I've simplified the CapX and you can download it here : mediafire.com

    (to generate a laser you have to hold an arrow or more and use the left click)

    See, I have a debug box. When I add into my debug box Cos(270) it writes 0 as expected. Also Sin(270) writes -1.

    So that's good.

    But when I try to concatenate Cos(270)&" / "&Sin(270) the cosinus is wrong. It gives a figure veeeeery small but not nul. So it writes something like "-1.8369701987210297e-16 // -1" instead of "0 // -1".

    Is it because of the cosinus ?

    Or because of the concatenation ?

    More importantly, can this mess up my computation for the laser's width in any way ? (line 27-28 of the Event Sheet 1)

    Thanks in advance for taking the time to reassure me <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

    Best regards

  • Damn, I realized I forgot to thank you guys for your answers. Sorry.

    Thanks to your help, I realized the while loop was totally optional in my case.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello everyone,

    Sorry to dig this old topic, but my question is in the title... and it is unsolved as far as I'm concerned :/

    R0j0's answer may be correct when the condition is related to an object, but what if it is related to a variable ?

    Simple example :

    • we are making a platformer
    • we have two variables, one reflecting the left stick direction (LStick), the other stating if the player is crouched or not (IsCrouching)
    • LStick can be set to "Up", "Down", "DownRight", "DownLeft"
    • we want to set up a loop, instead of three redundant loops, that says :

    while (LStick="Down" OR LStick="DownRight" OR LStick="DownLeft")

    then IsCrouching= "True"

    I've tried the "Pickbycomparison" but variables are not attached to an object so I don't know what to do...

    Many, maaaany thanks in advance for the one who'll be able to answer me =)

    (also, a quick side question : can you add an Else event after a While loop ? So that if the while loop is not working the IsCrouching is set to "False" again )

    Cheers