99Instances2Go's Forum Posts

  • For the - 9.

    Never forget that object with UID=0 exists. In this case the purple one has UID = zero. Without setting it to -9, the purple colour will not work if it is the first colour accessed by the touch.

    I could have deleted the first instance of color in the layout editor, so the first color gets a different UID then zero. But, construct tends to pack the UID's again in the layout editor, so that zero can/will show up again.

    I could have added a fake sprite to the layout at the very start, right after making the new project. Now i am sure that this sprite will have UID=zero. And not ever touching it will keep that UID=zero on that sprite. But how do i explain this in a little/short example.

    Better is to make the code account for a possible UID = zero.

    So, now, if i set previousTouched to - 9. And the first touch goes over the purple one, then the caught UID (zero) is different then -9, or, there is a change in the situation. We got to act.

    Also, in this case, when i set the default stat of previousTouched to any existing color UID, the color will not work when touched as first colour.

    So, there are 2 things playing here.

    1/ I only want to act if the touch is over a different color then it is over in the previous tick

    2/ i only want the color that the touch (when touching) is over to go in the state 'touched' (boolean = true). All other colors must go in the state untouched (boolean = false)

    About 1/

    There can be only one color with boolean 'touched' = true. I am sure of that.

    Therefor, if i (before changing anything in that state) set previousTouched to the UID of the 'touched one', then i store the UID of the color that had the state 'touched' in the previous tick (event 5)

    As long as the state 'touched' is not changed (and i will change it in event 7, later on) , it reflects the previous tick.

    Now, in the current tick, things could be changed. I first pick the color that touch is now/at this moment over. And that can be a different color then in the previous tick.

    ONLY if its UID is different (not the same as) then the one in the previous tick (previousTouched) i start the timer that is changing colors. (event 8)

    About 2/

    I need only the color that the touch is over to be in the state of 'touched'. I could make some complicated inverse or else condition to archive that. But it is a LOT more simple to just set them all in the state 'untouched'. And then set only the one, that has the touch over it, to 'touched'. You see ?

    Event 6 just sets them all to 'untouched' ( = boolean touched = false)

    Event 7 picks that only one the touch is over and sets its state to 'touched' ( = boolean touched = true)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The condition in event 8 picks 1 and 1 rock only.

    The actions work only and only on the picked objects, hence only on that 1 picked rock.

    Use a sub event (under event 8) containing > system > pick all (rock)

    Bring the rock > bullet disabled .. under that sub event.

    Or. Use a function to pick all rocks.

  • So that means 1 seed per peer, and to prevent missmatches over a longer time-frame i guess i would have to re-sync the seeds every 30 seconds ~ 2 minutes.

    Nope. Use same algorithm to produce noise on both sides. Exchange seed only once.

    Say, we use 3D Perlin noise.

    Then the noise plugin returns a random value for Noise.Perlin(x,y,z) that is always the same for the same x,y&z, but different for different seeds.

    Now you can produce noise by something simple as

    (random spread angle) = (random spread angle) + (Noise.Perlin(enemy.x,enemy.y,uncorrected spread angle))

    Uncorrected spread angle is, i suppose, an iteration from a base angle (base angle + 3, base angle + 6, base angle + 9, base angle + 12)

    Ofcourse, the deviation of the noise must meet you needs. The random (with the same seed) will be exactly (as exact as floating can be) the same on both sides.

    You might better of to choose a bigger deviation, and round(them) or floor(them).

  • I think that using an Array (as suggested) is the best solution.

    But, lets do it 'just for the sake of it' without an array. Not as a viable solution ....

    More to explain why attempts that rely on 'picking a newly created object in the same event' have no chance to succeed.

    It is fully (for a change) commented. (but the comments have no spellchecker, so excuse me for ....)

    https://www.dropbox.com/s/kgzh1hcy8yjxp ... .capx?dl=0

    Of course, i played false, because instances holding different values in 1 instance variable, is in fact an array. And that argument is also the best argument to not shy away from using arrays.

  • The expression Sprite.Platform.VectorX returns a negative number when moving to the left, positive when moving to the right and zero when idle.

    You can do the mirroring & the walk/idle animations under it, but only under the strict condition that you constrain the logic to catch the exceptions. And there are a lot exceptions.

    When Sprite.Platform.VectorX is less then zero you want the mirroring to happen, but the 'walk' can not happen when in the air, and also not when there is an 'attack' playing.

    The flow and the logic is not that easy. But in the end you will have to catch the 'attack' exception any way, and the 'crunch' and.......... etc.

    .... and the 'is at wall' when using only the triggers to animate, you dont want it to walk when standing still for a wall.

    So in the end, it will be a mix.

    Using the triggers for the 'mirroring', for starting the 'jump' animation, for starting the 'fall' animation, for starting an 'attack' .... & Using the Sprite.Platform.VectorX to fall back on the 2 defaults, "walk' & idle after any of the others ended and there is not other exception in play.

  • I dont understand your code at all.

    Plz read https://www.scirra.com/manual/75/how-events-work

    You pick 1 player. All the sub conditions start picking from that first pick.

    Hence, those that you wanna pick are not in the picklist to start with.

    Use a function to (broaden the picklist) start picking from scratch.

    Better is to use a family.

    Here is with functions:

    https://www.dropbox.com/s/4tmc0p3io8gea ... .capx?dl=0

  • Tap 4 spawn.

    Pinch for zoom.

    https://www.dropbox.com/s/fu42kbufwhmcu ... .capx?dl=0

    Although, that is probably not 100% what you want, cant look in the future, so the spawn happens on release.

    Need to give the player at least a little time to get that second finger on the screen.

  • Or, you made the Player Sprite global and you have it present in each layout.

  • Nice to see that you use the same logic. It also means that what i proposed as logic for using a joker applies to your logic.

  • To bound the edges to view port.

    For each sprite

    ___System > compare two values .. Sprite.BBoxLeft < ViewportLeft ( the compare does not pick !, why the for each)

    ________ Sprite > set x to ViewportLeft + Sprite.Width

    ___Else

    _________move the sprite as you are moving it currently

    ___System > compare two values .. Sprite.BBoxRight > ViewportRight

    ________ Sprite > set x to ViewporRight - Sprite.Width

    ___Else

    _________move the sprite as you are moving it currently

    or pick them this way

    System > pick by comparison > expresssion = Sprite.BBoxLeft .. Less than value = ViewportLeft

    For each sprite (if more sprites can exceed the boundary's at the same time)

    Ether way, you have to pick them.

  • (attached myself to this topic to follow updates, sorry 2 disturb)