dop2000's Forum Posts

  • Yeah, that condition prevents crashing. That's why you should absolutely definitely keep it.

    But you should also try to minimize the number of unnecessary saves, it's up to you how you do it. To tell you the truth, I've lost track of your changes a long time ago.. :) You can add a cooldown period, wait for a pause in mouse wheel scrolling, or require holding Ctrl or some other keyboard button and save undo step when it's released. Or there may be other methods, I don't know.

    You can invent a system that monitors z-order of all objects and signals when it changes, but I don't think it will worth the effort.

  • Why don't you just add and test? You could have done it in time you spent typing your comment..

    I was telling you many-many times - you need to prevent multiple saves from running at the same time! Adding this condition to the function will do exactly that.

  • Add a condition "isUndoSave is NOT set" to the "SaveStep" function. This will guarantee that another save will not start until previous save has finished. If you are saving too often, or the save size is too big, some undo steps may be skipped, but this is a minor issue comparing to all the bugs you can have from multiple simultaneously running saves.

  • And I'm saying that even 0.3s is not enough, especially if you anticipate users will be adding lots of objects. I've seen save/load actions taking more than 5 seconds.

    You need to make a proper system that doesn't allow two or more saves running at the same time.

  • Why did you make the delay even smaller? This means saving lots of unnecessary undo steps. Not only it can cause bugs, but also will make it more difficult for user to undo.

    Sure it works great on your PC, but on an older machine with a slow HDD saving a big project may take much longer time.

    Regarding the number of steps - it depends on the average size of each save. Add some objects, open browser console, it should tell you the amount of data saved, in bytes. Multiply by the number of steps - that's how much memory the array will take.

    I doubt you will run out of memory even with 256 undo steps, but a very big array may be slow.

  • Note that this method waits for a pause in scrolling, which is not an ideal solution in your case. If you keep this timeout at 0.3s, for users who scroll slowly (when they want to precisely adjust object size), undo will be saved every 0.3 seconds, which is still too frequent.

    If you set a larger timeout like 1-2 seconds, undo step will be saved with a big delay, during which user may do something else, for example delete the object. And this again can cause the situation when two undo steps are saved at the same time.

  • It's very hard to read the unformatted code you posted..

    Since you don't need a clean solution, the easiest one is to add all 20 characters to the layout and do this:

    System For each Character Order by random(1)
    Loopindex>9	: Character destroy
    

    This will remove all but 10 random characters. If they are different sprites, add them to a family.

    You can also add all character numbers to an array, pick a random index and remove it from the array:

    Repeat 10 times
    	Set r to int(random(array.width))
    	Create character with animation frame r
    	array delete element r
    
  • If the undo needs to be saved, and it is saved, then why did you wrote that it is a problem and that it doesn't make sense? (your words, not mine) :)

    English is not my first language either, so there may be a misunderstanding on my part. Anyway, I hope you'll get everything working exactly as you want.

  • You wrote "if I just press and RELEASE CTRL by itself... it will create an UNDO"

    If you are using the flag correctly, this should not happen. When you press and release Ctrl or any other button, without actually changing any objects, undo step will not be saved. Only when anything about the object has been modified (scaled, moved on z-axis etc.), then you set the flag and undo step will be saved.

  • I'm not sure.. This is "On create" event, so initial AnglesToRotate values will always be the same for all newly created instanced, and will probably be an empty string.

    Try adding Browser Log to each event, for example:

    Browser Log "RedLight UID=" & Spr_RedLight.UID & " AnglesToRotate=" & Spr_RedLight.AnglesToRotate

    Run the game in debug mode, open browser console and try debugging.

  • The problem here is if I just press and RELEASE CTRL by itself... it will create an UNDO which doesn't make any sense

    Sigh... We've been through this many times.

    You need to use a boolean flag IsUndoSaveRequired (or something like this). Set this flag to true when the object is resized. Check this flag when Ctrl is released and call SaveStep function only when the flag is true. If user just pressed and released Ctrl, the flag will remain false, and the undo step will not be saved.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Since you don't want to provide any more information, or your code, or your project file, I assume all you have is a bunch of circle sprites.

    You can use that green line sprite to detect groups of circles of the same color.

    Set origin point at its left end, set angle to 45 degrees.

    In a loop set line position to each circle, check if it is overlapping 4 circles, check if all 4 circles are the same color.

    If they are, mark them for deletion. Repeat for all circles on the board.

    Then set the line angle to 135 degrees and do the loop again.

    Then make the line size shorter, to cover only 3 circles, and repeat loops again for 45 and 135 degrees.

    Finally, destroy all marked circles.

    .

    Of course, this is an un-optimized method, there is room for improvement, but it should work.

  • Again, I don't understand your question. Dealing with angles in Construct is tricky. In many cases you can't simply compare angle1 with angle2. I advise using "Is within angle", "Is clockwise", "Is counterclockwise" conditions, and expressions like anglediff()

    For example, if you need to know if spr_Road.angle and intersection.anglesToRotate are very close, you can do this:

    anglediff(spr_Road.angle, intersection.anglesToRotate)<5

  • Not sure I understand. You can define an image point (for the yellow dot) on small sprites and do something like this:

    SmallSprite is overlapping BigSprite
    For each SmallSprite
    
    .. use the following expression to get the angle from the center of big sprite to the yellow dot of the small sprite:
    
     angle(BigSprite.x, BigSprite.y, SmallSprite.ImagePointX(1), SmallSprite.ImagePointY(1))
    
  • You can change the controls you use to scale objects. Make it Ctrl+Wheel for example, and save undo step on Ctrl released.