R0J0hound's Forum Posts

  • Nice to know C3 added that expression to the keyboard.

    Looking at my example again it can be simplified a bit by replacing:

    int(tokenat(widths, Function.Call("find",c),","))

    with:

    SpriteFont.CharacterWidth(c)

    I completely missed that. Will update the example shortly.

    Edit:

    example updated.

  • I skimmed that blog article. It certainly in an in depth list, but most of what we are doing here is just enough to do what we want. We aren't intending to make a comprehensive editbox.

    dop2000

    I like that example. Very console like. I noticed you have the same issue as I got where you can't type a "?". Anyways, the solution I came up with was to add an event listener in js that calls a construct function with "e.key" which is what key was typed taking into account shift and capslock. At least in C2 the keyboard object wasn't enough to get that.

    document.addEventListener('keydown', (e)=>{c2_callFunction('keyDown',[e.key]);});

    Here are some tests. The first hides the textbox by setting the css opacity to 0, and draws the text with the text object.

    dropbox.com/s/5xygyt0uo5zyz96/hidden_input_form.capx

    Here's another test that uses spritefonts with variable widths. It supports single line text and lets you type with any character in the spritefont. Clicking sets the cursor position and you can remove charters with delete and backspace.

    dropbox.com/s/4vww2hr0an2cdws/spritefont_input.capx

    Taking the idea further to support highlighting, ctrl moving between words, copy/paste, double click selecting words, and multi lines just require a bit more work but seems possible.

    Issues i encountered were the needing to get the keyboard input with js as mentioned above, and find() was case-insensitive, so I had to make a case sensitive one with a function.

    Here's how the spritefont was generated:

    construct.net/en/forum/game-development/tools-and-resources-27/spritefont-generator-168408

  • I agree with dop, there are pros and cons to making your own text input vs just using the editbox.

    To me, editboxes work well but you are limited how it can look, even with css. Making your own can go from fairly simple like dop’s example to trying to reproduce everything. Clipboard access is the tricky part in js.

    Another idea is to hide the editbox by setting the style opacity to 0. That would let you interact with the editbox but let you draw it as you wish. It’s just fiddly to make them match.

    As long as it works it should be fine. I’ve seem lots of games and software that don’t just use a normal os editbox and it’s seldom an annoyance.

  • The “trigger once” is throwing it off. Basically they all need to not be frame 1 before the event can run again.

    I’d do the logic under a “on frame changed” condition.

  • The tilemap has some expressions you can use to get that. Namely the row and column of the tile at a certain xy. Then you can use another expression to get the xy of the tile at a certain column and row. That will give you the tiles center then you can get the sides by adding/subtracting half the tile width/height.

    But you can calculate all that directly. For example if the tilemap is at 0,0 with a 32x32 tile size, and the player objects are smaller than 32x32, then this will give you the bounding boxes of each of the tiles the player could be overlapping.

    Gridx= int(player.x/32)

    Gridy=int(player.y/32)

    For i=-1 to 1

    For j=-1 to 1

    Tile at (gridx+i,gridy+j) != -1

    — left = (gridx+i)*32-32

    — right=(gridx+i)*32

    — top=(gridy+j)*32-32

    — bottom=(gridy+j)*32

    — resolve collision

  • An alternative if no one has the add-on is you can manually remove all references to it from the capx.

    Capx files are just zip files and you can access the .c2proj and .xml files for the layouts and events to remove it from them.

  • Wouldn’t setting the layout scale, as you would to zoom in with normal 2d games work?

  • Here's an idea how to make the bullets meander a bit before reaching their target.

    Basically this gradually increases the turning force, and uses sin() to meander in a curvy way. All the numbers in event 4 can be tweaked to change the effect in various ways.

    dropbox.com/s/ffnik6zpbie7vte/chaos_bullet3.capx

  • If it keeps sliding you have friction set to 0. That’s what your screenshot shows anyways. Set it to a value between 0 to 1 so it will slow down.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The order of the actions matter. Set the angle first, then move forward.

  • You won't be able to make it perfect by using a wait. I mean you can calculate how long it will take to rotate with time=(360/sprite.count)/speed, but since things update at 60fps you'll be off by 1/60sec or so which will add up. Plus, wait makes it harder to track what your events will do, which can make it hard to find the reason things aren't working.

    Conceptually you just need to rotate it a set number of degrees and then stop. Maybe with an ease?

    At any rate here is one way. The arrow keys change the goal angle, then the actual angle changes toward that. It will robustly stop at the correct angle.

    dropbox.com/s/d9ljfr2sade5orp/revolver_menu.capx

    There may be a simpler way too, but this should be simple enough to understand so you can use it in your project and customize.

  • The idea is the pinned object is just a bit bigger to visually hide the gap. All interaction/collision would be with the object underneath.

  • Looks like you can do it by recursively picking each child and adding up all the child counts. Simpler enough if all the object types are the same from the looks of it but it would complicate things with differing types.

    Function descendentCount(uid)
    Sprite: Pick by uid: uid
    — local number count
    — set count to sprite.childCount
    — Repeat count times
    — sprite: pick “sprite” child loopindex
    — — add descendentCount(sprite.uid) to count
    — set return to count

    Or depending on how the js api lets you access children it may work better because it doesn’t care about object types.

    function descendentCount(obj)
    {
     let count = obj.children.length;
     for(let i=0; i<obj.children.length;i++) {
     count+=descendentCount(obj.children[i]);
     }
     return count;
    }
  • There’s nothing amiss. The physics engine has a thing called “slop” where it adds a slight gap between objects to make the simulation more robust. Anyways, this isn’t controllable in construct.

    A solution is to make the collision polygon slightly smaller so the gap isn’t visible. A more exact solution would be to have an a separate object pinned to the physics object. Just add 1 to the height and width.

    At least that’s an immediate solution based on what we can do.