AllanR's Forum Posts

  • EDIT: just saw dop2000's version - I like the way he did it better than mine! :)

    OhhBaby in your first post you asked why it isn't working. I tried your file, and had it log when it created each item (the tickcount at the time it created a sprite).

    I would argue that it is doing exactly what you are asking it to do.

    in the first function it waits half a second to create each top sprite - and they are created at 30 ticks, 60, 90, 120, and 150 ticks.

    after each top sprite is created you call the bottom function and have it wait 1 second before creating each bottom sprite.

    the bottom sprites for the first top sprite are created at 90 and 150 ticks.

    the bottom sprites for the second top sprite are created at 120 and 180 ticks

    the bottom sprites for the third top sprite are created at 150 and 210 ticks

    the bottom sprites for the fourth top sprite are created at 180 and 240 ticks

    the bottom sprites for the fifth top sprite are created at 210 and 270 ticks

    so, maybe that isn't what you had in mind, but it is waiting the amount of time you ask it to. You end up with a couple sprites created at 90 and 120 ticks, 3 at 150 ticks, 2 at 180 ticks, etc.

    I am guessing you wanted it to wait until both bottom sprites were created before it went on to create the second top sprite. You added the "wait for previous actions to complete" after calling the bottom function but that would only affect actions added immediately after that point - it doesn't prevent the loop above it from continuing to run.

    I made a sample how I would probably do it... The CreateBottom function hasn't changed, but the CreateTop had to be done differently.

    https://www.rieperts.com/games/forum/asyncLoop.c3p

  • the way I made the circles was by using the paint brush tool - I set the brush size to the side of the sprite (250 or 500), put the mouse in the middle and clicked. Then set alpha to 0, made the brush smaller (about 246 and 494 I think), and clicked in the middle again.

    You could make a 1 pixel circle by reducing the brush by only 2 pixels (leaving 1 pixel on each side), but I thought the circles didn't look as solid as the grew larger... for the 500 pixel circle I reduced the opacity as it grew to see how that would look...

  • or you could start with a higher-res circle and a lower starting scale rate...

    I made a 250x250 circle and a 500x500 circle

    https://www.rieperts.com/games/forum/testGrowCircle2.c3p

  • you might be able to calculate the text width, and if it is greater then the space available reduce the size of the font.

    with sprite fonts you can adjust the character spacing...

  • the array is two dimensional - each row holds the y coordinate of the object, the UID of the object, and the object type (P for Player, B for Background family, O for Object family).

    when you sort an array by the x axis, it will sort each row by what is in the first column (that is why I put the y coordinate in first).

    at the start of the Sort function I set the array size to (0,3,1). That clears the array, and leaves room for three columns on each row.

    For each object, we push it's y coordinate to the front of the array (which is row 0, column 0). Then we add the UID and type to columns 1 and 2.

    once all the objects are in the array, we sort it by the x axis. That will put the lowest y coordinate at the top, and the highest y coordinate at the bottom of the array - which is how we want the objects arranged on the screen.

    then we read through the array, bringing each object to the top of the layer. So, in the end, we only loop through each family once, and the final array once.

  • the quickest way I could think of was to throw all the y values in an array (along with the UID and "type") and then sort the array. Then loop through the array picking the appropriate object by UID and moving it to the top. That way it can all be done in one pass.

    I added the player object as well, and call the sort function whenever the player is moving (no need to constantly resort if nothing is changing).

    https://www.rieperts.com/games/forum/Zsort.c3p

  • dop added a Blank sub-event to the keyboard event. Then you can add the actions...

  • it isn't just 9patch... sprites also are affected, and probably other types as well.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • well, it that case, try saving, rebooting... could be a driver issue or some browser plugin, try updating the browser, etc.

  • sometimes it is caused by "Preview Effects"

    you can turn that off by going to the Project Properties on the Properties bar on the left, click on Project Properties, scroll down to the Editor section and click Preview Effects to uncheck it.

  • I just tried the file from your bug report and the bug is quite clearly pasting the object from the viewport's origin rather than the drawing canvas' origin.

    I believe Ashley when he says the code there is extremely complicated, but knowing exactly what to look for should help...

    as a work around all you have to do is make sure the top left corner of the canvas is at ViewportLeft(0), ViewportTop(0) and it will paste where you want it. It doesn't matter how wide or tall the canvas is. I tried with unbounded scrolling just to make sure it wasn't assuming the top corner is 0,0. And it is pasting based on the viewport left and top. Making the canvas origin top left (instead of center as in your sample) makes it easier to position.

    Is that a limitation you can live with? Is there a reason you need to paste with canvas somewhere else? As long as you aren't destroying objects in the same tick as pasting them you can move the canvas and objects as needed, paste, and move them back. Future updates and fixes won't break that.

  • sounds like a yes to me. if you are complying with the license, then you have the right to use it.

  • This is what I do - resize the canvas to match what the PlatformInfo reports as the window size. And do this any time the browser resizes (orientation changes or user changes window size).

    This allows you to use the whole screen and keeps 1 pixel = 1 pixel, no scaling, which is nice if you need to draw a lot of 1 pixel wide lines (and want it to look consistent across the screen with no blurring).

    https://www.rieperts.com/games/forum/Canvas_Resize.c3p

    you have to make sure your layout size is big enough for any screen someone might use. Using Unbounded scrolling is also an option, but then the top left corner is not always 0,0 and you have to work harder to keep things on screen the way you want.

    in my sample file above I have a green box that is 1280 x 720 and an orange box 720 x 1280 just to help see how much of the layout you can see.

  • EDIT: blackhornet beat me to it - I should have refreshed :)

    Actually, the rules around creating objects and picking are slightly more confusing.

    The new object is picked in the event that created it (unless a loop is creating multiple objects - then the last one created will be the only one picked).

    during that event (or any functions you call from that event), you can only pick the new object by its UID (or "Pick Last Created"). So, if you call a function and want to use the new object, you must pass the UID in so that the function can pick it. You can't pick by instance variables, or any other way (x, or y values, etc.)

    After the top level event that created the object, you can then pick it by all the normal methods. You don't have to wait until the next tick - just the next top level event. That is when C3 finishes the process of creating new objects.

    What a lot of people will do is add a "Wait 0 Seconds" action after creating an object. This defers further actions until the end of the current tick, so by then the object is pickable with all the regular methods. I think that is where the "you must wait until the next tick" idea comes from. But I have seen people get themselves into lots of trouble by misusing Waits, so I think it is a better idea to set up your eventsheet to use some kind of flag, and access the new objects in a different top level event.

  • ok, just uploaded the file for you to look at...

    I made lots of little changes - I tried to put in comments to explain what I was doing.

    Some of the changes were just to help debug - I made it so the mouse wheel zooms in and out, and pressing the Z key zooms way out to help see what is going on. I greatly increased the line of sight for the Ally troops, and reduced the health of the enemies so I didn't have to move units very far and they would need to find new targets quicker. I changed the unit selection box so that it can be dragged left or right. I also made it not start selecting until you moved the mouse a fix pixels because if you clicked right on a unit, the selection box would try to start selecting and often unselect the unit you clicked on.

    I made the Ally troops a container, they each have their own select box, health bar, ammo bar and a target symbol (so I could see when they chose a target). Putting all that in a container automatically picks those elements when you select a unit. (I also made a stat window pop up when you select a unit for testing).

    I added some more instance variables - TargetDelay, ShootDelay, AngleToTarget... to control how often they look for a target, and fire at it. This works better than using the Every X seconds, which can add confusion with picking. I think the main reason most units weren't firing was because it was looking for a specific angle to the enemy first and most of the Ally troops were at angles that were preventing them from firing.

    I would consider putting all units in a family to simplify the code a lot further. They all need to do basically the same things - just with different parameters that can be set through the family instance variables.

    Your world map is huge! I would look at making that smaller - I made the sprite smaller just to save space on the upload, but didn't make any other changes there.

    https://www.rieperts.com/games/forum/TerritoryWar.capx