Dalal's Forum Posts

  • "Down arrow is down".

    That's the problem. Use 'Down arrow is PRESSED'.

    'Is down' will keep firing as long as the key is down. 'Is pressed' will only fire once when the key is down. It's the same as going 'Is Down' + 'Trigger Once'.

  • To check if a tile is a 'topmost' tile, check if there is a tile directly above it. If not, then change it's frame.

    This could be done using 'Overlapping at Offset':

    is 'Tile' overlapping 'Tile' at offset (0,-1)'

    This will move the 'Tile' up a pixel and test for overlap. Inverting this condition will effectively test whether it's the topmost tile or not.

    For bottom and sides use offsets (0, 1), (-1, 0), (1, 0) respectively.

    EDIT:

    If you can figure out (roughly) how your tiling engine works, the best approach would be to tap into its array to figure out if there's a tile above the one you are testing. That would be the easiest and the most straightforward.

  • How could I test if a value is NaN in C2?

    Edit: Figured out right after posting. One way to do it is to compare it against itself. If it's not equal to itself, it's NaN. So you'd do something like: if (Variable != Variable) { ... }.

    I'm leaving this post here for reference in case someone else ends up needing this.

  • Any more updates on this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Would it be worth having a sub-forum dedicated to those that are already well versed in C2 and/or game development and/or programming? Perusing the forums, I've seen that questions from advanced users tend to get drowned out by much more basic questions.

    This lowers the visibility of 'tough' questions considerably, dampening the potential for several deep, intricate discussions on C2, which would help us all learn, invent and discover new C2 programming techniques.

    An 'Advanced Users' sub-forum might also provide some of these benefits:

    1. More targeted questions and answers. Advanced users would get more thoughtful answers from people who truly understand their questions. Advanced users could also phrase their questions in more technical terms without the fear of scaring people away, using terms like 'scope', 'type casting', etc that those with a programming background might connect to and those with deep C2 knowledge would be able to learn and apply towards an understanding of traditional programming.

    2. Those coming from a traditional programming background could better learn to grasp the C2 paradigm by asking questions from a programming standpoint. I've found that programmers new to C2, for example, will notice the 'For Each' condition and have a tendency to use it to go through each instance even when they don't need to (For Each 'Enemy' rather than simply 'Enemy' collides with 'Bullet'). It can ease the transition into the C2 world and help them see how simple things can be and how deep they can go.

    One might argue that someone from a programming background isn't necessarily an advanced user of C2. True, but this forum would still be the place for them. The beauty of C2 is that if someone is an advanced user, they automatically have at least a rudimentary understanding of fundamental programming concepts, so they can help people that are asking questions from that end of the spectrum.

    All in all, I think it could help the growth of the C2 community and help us all learn new things. What do you think?

  • Link to .capx file (required!):

    N/A

    Steps to reproduce:

    1. Open new empty C2 project

    2. Create an event

    3. Create a sub-event within that event

    4. Minimize the parent event

    5. Zoom in a ton (dramatically, just to be sure)

    6. Expand the parent event and observe the "cut-off" sub-event

    7. Zoom to 'refresh' display and fix issue

    Observed result:

    Text is squeezed and cut-off for sub-event.

    Expected result:

    Text should look normal for that zoom level.

    Browsers affected:

    N/A

    Operating system & service pack:

    Windows Vista SP 2

    Construct 2 version:

    138.2 R2

    NOTE:

    I'm using an outdated graphics card on this machine, which may be part of the issue. If this bug cannot be reproduced on any other machine, then I apologize. I wanted to report it just in case.

  • Link to .capx file (required!):

    N/A

    Steps to reproduce:

    1. Start a new C2 empty project.

    2. Insert a new Sprite to the layout.

    3. In the Animation/Image editor, select a non-square area ex. 200x90, and then use the crop tool to crop to it.

    4. Hold shift while dragging the selection tool to make a square selection that stretches outside the image canvas (now rectangular). Just to be sure, try to encompass the entire canvas and then some.

    5. A square should appear (smaller than the selection) that extends outside the image canvas. This in itself is unexpected.

    6. Now click the Crop tool. C2 will crash.

    Observed result:

    After holding Shift to make a square selection and letting go, a square selection appears that extends outside the canvas. When clicking crop, C2 crashes, presumably because the selection unexpectedly extends to outside the canvas.

    Expected result:

    After holding Shift to make a square selection and letting go, the resulting selection should be bound by the image canvas. When clicking crop, C2 will not crash because the selection is still within the canvas.

    Browsers affected:

    N/A

    Operating system & service pack:

    Windows 7 Pro SP 1

    Construct 2 version:

    r137

  • I should have clarified. I'm doing a lot of specialized collision detection (my overlap detection is not simply the C2 condition 'Is Character Overlapping Obstacle'). The push out that comes with Custom Movement cannot test for collisions at an offset for example. I have slopes which the character walks along using his bottom middle point and Custom Movement's push out would try to push him out when it's not supposed to.

    Anyway, I think I solved the problem using the following technique:

    On the character's initial overlap with obstacle, offset the character to match the sub-pixel offset of the obstacle i.e Set the position to the following:

    floor(Character.Y) + (Obstacle.Y - floor(Obstacle.Y)

    Now resume the loop as normal, and by the end, the character should be a perfect whole pixel above the obstacle.

    It works quite well so far, except for a subtle jitter when walking up slopes, likely from the offset matching that I'm doing. Hmm... any other ideas are welcome.

  • Thanks for sharing that approach. Because of all varieties of slopes, that approach probably won't work in my case.

  • I'm writing a custom platform engine for my game, and I had a question about 'pushing out' an object from another object. In simple terms, say Mario is falling and he overlaps a platform. We now need to perform a 'push out' loop where we slowly move Mario up until he no longer overlaps and is 'flush' with the platform.

    C2 uses sub-pixel precision, so pushing out an object pixel by pixel will yield inconsistent results visually i.e sometimes Mario will be a pixel too high. I've found that pushing out an object at less than a pixel per iteration is more stable, but no matter how small I go (even at 0.01 px/iteration), Mario is still vibrating ever so slightly, giving a blurred look.

    Something seems fundamentally wrong with my approach. What's the best way to implement a 'push-out' so that by the end of it 'Mario' is no longer overlapping the obstacle and he is flush with it?

  • Yeah, I can see that. Without looking at the code, I always got the sense that Families were a little restrictive in how they were set up behind the scenes, judging from the interface where you add/remove objects.

    Perhaps what is needed is a new feature entirely separate from Families that focuses on inheritance rather than merely being able to reference several objects at once.

    I'm visualizing something like a Parents property that can be set in the editor. When you click on it you can choose a sprite (or applicable object) to inherit from, and just like that all variables and behaviors are inherited.

    That would be a really advanced feature that I'm sure is hard to implement, but some kind of advanced inheritance system in Construct 2 would be extremely useful. I hope Ashley can consider it for a future release.

  • Ah, good idea. I will probably use a function in my case because I'm going to have a lot going on. Thanks!

  • What would be the difference between sub families and simply putting an object into multiple families as can already be done?

    The main difference is that a sub-family would inherit the variables of its parent family, whereas two separate families would have no connection to one another.

    Say we have a family called Bullet that moves left and right at a set velocity and kills stuff. Then we have a sub-family called ChaserBullet that changes its velocity in order to chase someone. ChaserBullet can now access the parent family's velocity variables in order to modify them.

    Why wouldn't the approach of multiple families work? Because then, ChaserBullet cannot handle the logic for its child objects. There will be duplicated logic for each child, which defeats the purpose of the ChaserBullet family. Only the children will have access to all variables.

    I assumed Sub-Families existed until today (Families are treated like objects in almost every other way). I needed them and they weren't there, so I had to come up with a work-around, which did the trick although it makes the logic a little more convoluted and isn't as clean when assigning families. You basically have to make sure that anything that is ChildFamily is also ParentFamily.

    Someone asked about this a little while ago and Ashley more or less said it's not happening.

    Oh! I missed it when I searched. Could you point me to the thread? Thanks!

  • It seems like the next logical step for families is to support sub-families. Families are already treated like normal objects in any every other aspect. In a relatively complex game such as the one I'm currently making, multiple levels of inheritance would be really handy.

    What's the demand like for this feature? Are there plans to support it in the future?

  • C2 doesn't do sub-families (yet), so I'm using an approach where I assign the effective parent family to every effective child family.

    If I'm working with an instance of the ChildFamily, how can I pick it as the ParentFamily? For example, I'd like to do the equivalent of this:

    ChildFamily collides with Bouncer:
    + Pick ChildFamily as ParentFamily:
         -> Set ParentFamily.VelocityX to -50
    

    EDIT: SOLVED

    I think I found a solution and I'd like to share it here for reference. Whenever you'd like to pick as another family within a condition, run a ForEach loop for the ChildFamily. As a sub-event in the loop, Pick the ParentFamily by the UID that matches the ChildFamily. Since UID is a completely unique identifier for the object, this will work perfectly. Here's the above example working with my solution:

    ChildFamily collides with Bouncer:
    + For each ChildFamily
      + ParentFamily: Pick Instance with UID ChildFamily.UID
        -> Set ParentFamily.VelocityX to -50
    

    I hope that in the future C2 will natively support sub-families. It will make C2 that much more awesome.