dop2000's Forum Posts

  • I am making a mobile game and want to detect roughly if the screen (window) size is closer to a phone or a tablet. Basically, if it's bigger or smaller than 8".

    I'm reading the documentation for PlatformInfo, but can't make sense of it.

    I found an old post where Ashley says it's possible to estimate screen size from CanvasCss Width and Height. But I tested on my phone and PC screen with the same resolution, and by changing display scaling settings, I get vastly different results.

    • 6" mobile screen set to smallest scale: CssHeight=510, DevicePixelRatio=2.1
    • 15.4" PC screen set to highest scale: CssHeight=618, DevicePixelRatio=1.75

    So obviously this method doesn't work.

    ChatGPT says I need one more piece of information: the PPI (pixels per inch) or DPI (dots per inch) of the screen. Without it it won't be possible to estimate the physical size.

  • Loopindex doesn't work in For Each element loops. Either use System For loop, or Array.CurValue expression.

    Actually, that's not even "For Each element" loop on your screenshot, it's "For Each instance".

  • But what if we prefer to keep the original sprite orientation? I found that we can offset the angle somehow

    I don't know, it may be possible.

    Another option is to create two versions of the skeleton in the editor - normal and mirrored. Configure them as templates. And when you need to mirror it - destroy one hierarchy and create another in its place.

  • The main issue is that your sprites are rotated. You can select the lower leg sprite for example and mirror it in the layout editor - set width to negative value. You will see what happens to it.

    You will need to rotate the images in some external editor and set their angle to 0 in Construct.

    Also you need to disable Sine when the hierarchy is mirrored.

    Here is an example:

    dropbox.com/scl/fi/rhek2x89kjxmqzgxofrl8/test-mirror2.c3p

  • without using clones

    I don't think it's possible. You can use a clone sprite or paste the image to drawing canvas.

    Here is my old demo

    howtoconstructdemos.com/animation-frame-change-with-morph-fade-capx

  • So you have coin -> particle object -> effect sprite. The effect sprite is always spawned at the particle object position. If you know which coin the particle object is attached to (say with hierarchy or pin), you can accurately pick that coin.

    EffectSprite On Created
    Particle X=EffectSprite.x
    Particle Y=EffectSprite.y
    Particle pick parent Coin
    

    or simply:

    EffectSprite On Created
    EffectSprite is overlapping Coin
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use relative paths like ".keyname" to access values.

  • So what JSON string do you see in browser console?

    Not sure why you are storing each object as an array. Try this instead:

    Use "Set Value" action instead of "Push"

  • On the first screenshot - remove "Wait 0.2" and "Wait for previous action to complete", they are not needed.

    On the second screenshot - you are saving values to Local Storage on every tick, this is a big no-no. Local Storage operations are asynchronous, they require time to complete. You are basically reading and writing values in Local Storage at the same time, this is why they reset to default.

    You should only save to LS when it's safe to do so. For example, at the end of the level.

  • The only solution I can think of is to check which coin is the nearest (or overlapping) when the effect object is created.

  • I think you need to disable unbounded scrolling in layout properties.

  • So you need to smoothly change the parallax from 0% to 50% for example? You can use lerp, but it needs to run on every tick:

    Every tick: Set layer "foo" parallaxX to lerp(LayerParallaxX("foo"), 50, dt*2)

    It may be easier to use Tween behavior - add it to any object, ran a value tween from 0 to 50. While it's running, set layer parallax to tween value. With tween you will be able to choose different easing functions, which is not possible with lerp.

    I'm not sure what can be done about "pixel perfect".

  • Can someone confirm that Create and Destroy are asynchronous actions? I did not expect that.

    No, they are not. "Wait for previous action" in this case works similar to "Wait 0" - it delays the execution until the end of the tick. But I don't recommend using "Wait for previous action" like this, because in some rare cases it may actually wait for some other async action to finish.

    The problem with Create and Destroy actions is that they are not performed instantly. Until the end of the event or end of the tick object counters may not be updated, and other events (or functions you call) may not be aware of the created or destroyed instances.

    There are a few ways to work around it:

    1. Add "Wait 0" after Create action. This will delay until the end of the tick, so use with caution as it may break the logic.

    2. Pick newly created instance by UID or using "System Pick Last Created" condition.

    3. Use the next top-level event to update the counters.

  • Using the layout name in the function call sadly won't help me because I also have a Pause menu that appears in most layouts. Some layouts have both the pause menu and another menu.

    I think you can still use that system. Say, if the game is paused, try to call function inputPressed_layoutname_PauseMenu

    If it doesn't exist (catch branch in the script) - call inputPressed_Common_PauseMenu