oosyrag's Forum Posts

  • You can also do it with a loop. Here's an example to get the low and high x:

    global number low=0

    global number high=0

    every tick

    --- set low to infinity

    --- set high to -infinity

    for each sprite

    --- set low to min(sprite.x, low)

    --- set high to max(sprite.x, high)

    That is exactly what I was looking for, thanks R0J0. I was having trouble wrapping my head around how to keep only the lowest or highest value in a loop. I had tried comparing each value to the one before it, but that would result in issues where the order the values were checked would matter.

  • I can make an example later, don't have C2 in front of me.

    But basically just think of an array as a spreadsheet, pretty simple. You can have one column for each level, and 3 rows which represent each star. In each cell, a 0 would represent not collected, and a 1 would be collected.

    When you collect a star, you would set that star's position in the array to 1. This way, if it was 0 before, it would change to 1, and if it was already 1, nothing would change.

    Then run a loop in the array, for each xy, that adds everything in the array. That would give you your collected star count.

    Example to come tomorrow!

  • As long as there is no way to collect the star again after it has been collected (the star no longer appears on subsequent plays) it should work fine.

    Otherwise, you'll need a flag system to keep track of each star and it's state, if it has been collected before or not. An array may be a more suitable method of data storage in that case.

  • Same answer? Or maybe I still misunderstand...

    Whenever you collect a star on any level, add it to a global variable counter. You now have the total number of collected stars from all levels.

    Global variables are global in that they keep their value across layouts.

  • Sorry it's not the value that's unknown, it is the number of them.

    For example, I can get the distance to each image point on a sprite, and I want to track the nearest/farthest one. But the number of image points may vary, depending on the animation frame/state, so I can't just use the min/max expressions...

  • Got it, it was instance 0. But first you may need a "pick all sprite" condition. The IID is an indexed list of only currently picked objects - so depending on how you had your events set up, if you just created one, that would be the only picked instance, therefore Sprite(0) is that one. If you pick them all, Sprite(0) is the oldest. Here is an example - https://www.dropbox.com/s/am9vst1j6bl6ily/iid.capx?dl=0

  • Whoops maybe I was backwards. If 0 is the newest, then Object.Count-1 should be the oldest.

  • https://www.scirra.com/manual/124/system-conditions

    [quote:1yn1gpzj]Pick Nth instance

    Pick the instance at a given place in the internal list of picked objects. This is most useful used in sub-events to act on separate instances. For example, in a "Sprite collided with Sprite" event, Pick 0th instance and Pick 1st instance can be used to act on each instance involved in the collision separately.

    If all objects are currently picked, this condition can also be used to pick an object by its index ID (IID). For more information, see common features.

    After picking the 0th instance (oldest), you action (destroy) will then only apply to that instance.

  • I don't think three is anything built in. What would be your usage?

    Actually I would probably have a seperate dedicated semi transparent sprite with angle markers I would use as a reference for ranges when doing level design. Just drag it around to wherever i need it and destroy on start of layout.

  • How do you want them to spawn then? You can position them however you want after creating them.

    One way is to move at angle, for example 20 pixels at random(360) degrees.

  • You can add an animation frame to your character for debugging purposes only. Just replace the character sprite on that frame with a circle with width/height of range*2. Similar idea if you want a cone.

  • System-repeat.

    ceil(random(5)) is the expression for how many times to repeat. Ceil() rounds up.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry about that, it should be repeat tokencount(AJAX.LastData,newline).

  • Use a global variable to keep track of total stars collected. For example lets call it TotalStars.

    On star collected - (System Actions) Add 1 to TotalStars.

    Then to display, you can use a text or spritefont object to set text to TotalStars.

  • On Asteroid Destroyed

    Repeat ceil(random(5)) times - Spawn Minerals