Phyvo's Recent Forum Activity

  • Your loop is actually running 11 times (because there are 11 numbers in a list of numbers from 0 to 10). You just can't see it because you're spawning all the enemies on top of each other instantly as Vee said. To better see what your setup does add a "wait loopindex*0.1 seconds" action to your loop and put "add 1 to current enemy count" immediately before the wait and your "create object one" action immediately after the wait.

    One note about the wait function in loops: wait operates in parallel, that is, if you had "wait 0.1 seconds" in a loop your loop would just create all 11 objects 0.1 seconds later. In order to have each repeat wait a different time you need the loopindex variable.

  • Simply texting for the x position to be the same is unlikely to work because Construct can only test an object's position so many times per tick and moves objects multiple pixels at once.

    I see two main solutions for this.

    Probably the more elegant one is to, once it's overlapping, predict when it's going to cross the next tick using dt (there's more information on that if you search the manual). dt times its speed X vector will give you the number of pixels it will move on the next tick. With this you can then test it's approach from the left side using if ((stopper.X - bullet.X) < (bullet.VectorX*dt) and stopper.X > bullet.X), with another modified expression for if the object is approaching from the other side (stopper.X < bullet.X). If true you then set its speed to 0 and use set X to put it in exactly the right place.

    If you're really not comfortable with expressions (though I suggest you do get comfortable with them at some point), another solution would be to create two new invisible objects 1 pixel wide that mark the left and right sides of the stopping object. When the bullet collides with the invisible objects with the correct trajectory (VectorX < 0 for the left one and VectorX > 0 for the second one) you then force the bullet into the precise position (with set position X) and set its speed to 0.

    I hope this helps!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Uh, just a note, I screwed up saved over my latest capx so the file lacks the scoring system, so questions 2 and 3 are kind of moot. I'd still like to know what to do about nonstatic function parameters and the unhelpful behavior of local variables though.

  • I have been working on stuff with Construct 2 for several days, forgive me, I have SO MANY QUESTIONS.

    1. I can't get enemies ("Sprite") to home in on what the player's ("Sprite2"'s) position was 2 seconds ago (instead they continuously move straight towards the player). I was hoping to do it with local variables but they appear to not be unique across multiple instances of the same event.
    2. When the player jumps on an astronaut text is supposed to be created showing how many points you got for the jump. I've narrowed this down to my "PointKillDisp - set text to" action (disabling it removes the problem) but have no idea how it's causing it.
    3. When the player jumps on consecutive enemies a multiplier text object (named "Multiplier") appears to show their bonus. It's supposed to change color randomly and rapidly but the wait action, loop events, and perhaps picking mechanics continue to be an enigma to me.
    4. This is not in my project file but I think the question is simple enough. Is there a way to make function parameters "static" like you can with local variables? In a different project I had a function using wait actions to rotate a sprite over time and I had to set every parameter to a static local variable to make it work. Given problem #1 this could be a major problem if multiple instances of the function are called at once.

    Thank you very much for your help. I used to do some very basic programming in python but a lot of this event stuff is not very clear to me.

    dropbox.com/s/w615hjt3tdz027j/mygame.capx

Phyvo's avatar

Phyvo

Member since 17 Jan, 2013

None one is following Phyvo yet!

Trophy Case

  • 11-Year Club
  • Email Verified

Progress

12/44
How to earn trophies