AllanR's Recent Forum Activity

  • 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...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • it isn't just 9patch... sprites also are affected, and probably other types as well.

  • 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

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