AllanR's Recent Forum Activity

  • 99Instances2Go

    I have played around with Regex a few times - and it does come in extremely handy in many situations...

    but I really understand very little of the actual syntax or how to build an expression. I usually just google what I am looking for and then copy and paste.

    the trick is usually adapting the code you find to work in C2. A google search for "regex format number" will find javascript code like this:

    function formatNumber (num) {
        return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$&,")
    }
    [/code:dm8cb1vx]
    
    to make that work with C2 you need to take the portion between the forward slashes to be the expression:  "(\d)(?=(\d{3})+(?!\d))"
    (but don't include the forward slashes).
    anything after the second forward slash are the flags (in this case just "g")
    (which means global or look for all occurrences - which is the most common flag).
    then the part at the end is the replace string ("$&,")
    (in this case it means insert the matched string and insert a comma).
    
    so you end up with an action in C2 like this:
    
    Set text to RegexReplace( str(num), "(\d)(?=(\d{3})+(?!\d))", "g", "$&,")
  • if you want to add 1 to GroupFrame every 0.5 seconds, you dont need to create a loop, and slow the loop down...

    you just create an event: Every 0.5 Seconds, with an action: Add 1 to GroupFrame

    (The event sheet as a whole is already a loop... you don't need to put a command like that inside another loop.)

  • Unconnected

    It would really help if you posted a sample capx file and let us make some suggestions.

    You had trouble finding a loop with Wait built in because you can not slow down a loop. That is not what Wait does.

    The code on an event sheet runs really fast - 60 times every second. And the code can execute thousands of commands every tick without any trouble.

    Wait defers the code immediately after it, but the event sheet continues to run at the same speed (blazingly fast). That is why GroupFrame was getting to 25 so fast - before you can even blink.

    I get the feeling you are making this more complex than it needs to be. You seem concerned about having to do too many variable checks, but Construct2 can easily check 624 objects per tick. The problem may be that it does it too fast. That is why you have to structure things in entirely different ways to slow things down.

  • COVERR

    at line 21 you are checking if animation "felling" is not playing, then set animation to idle.

    well, "felling" is never playing, so the animation is always getting set to idle.

    you should be checking if "felling"&self.a is not playing...

  • Maxum

    the extra digits in the decimals is just how computers handle precision. To fix that you will have to Round(NumInput*100) / 100 (or however many digits you want.

    then you can format the number with one line by using RegexReplace...

    set the textbox to: RegexReplace(str(NumInput),"\d{1,3}(?=(\d{3})+(?!\d))","g","$&,")

    Edit: the only problem with the Regex code above is if there are more than 2 digits to the right of the decimal point, then commas will be inserted there as well.

    In that case, you can use: RegexReplace(str(NumInput),"\d{1,3}(?=(\d{3})+(?=\.))","g","$&,")

    but this version requires a decimal point, otherwise it wont work!

    This would take some more work if you want to zero pad the decimals so there is a consistent number of digits after the decimal point.

  • manukeo

    the player is probably getting stuck on the collision polygon. You can add points to the polygon to help follow along a curve. but it doesn't take much of a bump for the player to get stuck.

    I seem to remember a plugin that would push objects out of a solid, but I am not sure that is the problem here.

  • AnD4D

    text boxes do not dynamically grow, so you must have made one of the boxes bigger than you want. You can change the Wrapping in the properties from Word to Character. If it is set to Word and your text has no spaces, then it will display nothing if the text doesn't fit.

    You could also truncate the text, or edit it in some other way when you insert it into the text box...

    without seeing more about what is happening, it is hard to say...

  • Unconnected

    if the objects ONLY get created or destroyed as a direct response to the player's input, then you don't need to check their status every tick, or ever - unless the player takes action.

    When the objects are created (and given an initial status of 1) you would start the creation animation. You would also need an event: On Animation "CreateObject" Finished to set the status to idle (and show the idle animation if necessary).

    When the player destroys a group you can set the status to 2 and start the destroy animation. Then an On Animation "DestroyObject" finished can remove the object from the screen.

    By using triggers like that, there is no need to constantly check what is happening to the status of an object.

  • Maydie

    when you create objects, the instances can not accessed until the next top level event. (that is why they can be accessed outside the On Start of layout).

    But they can be accessed in the section where they are created, so you could insert them into the array as they are created... (which is what I was doing when the water is created).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • well, you can download the capx from the tutorial page (near the top, on the left) swipe2.capx

  • Maydie

    yes, it looks like you are calling them correctly.

    However, when the water is created, it is only looking for places that are not water - so it could put water over a tree...

  • Maydie

    when you are adding the trees to the array, you are using their screen coordinate ( tree.x ) ...

    just took another look, and you must have updated the image. try floor(tree.x/32) and floor(tree.y/32)

AllanR's avatar

AllanR

Member since 21 Nov, 2013

Twitter
AllanR has 23 followers

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Popular Game One of your games has over 1,000 players
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

19/44
How to earn trophies