Many questions!

0 favourites
  • 5 posts
  • 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

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

  • for 4. you could use your own stack

    create an array, name it stack, give it the size 0,1,1

    save your function parameter by doing stack.push(back, value, on X-axis)

    after your wait action you do a

       set object.angle to stack.front

       stack: pop front value.

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

    https://www.dropbox.com/s/w615hjt3tdz027j/mygame.capx

    1. local variables belong to the group or event. If your function has local variables then any call to the function will use that local. What your looking for are instanced variables. These shuold be stored in the sprite that you want the event to happen on.

    4. Events can't have static parameters. It just isn't done in programmer and it's would be against the purpose of functions with parameters. Again if your requiring a static variable for a specific object. Then use instance variables on the object type or family. This way the function call can just use the variables from the object and doesn't require paramters.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 2 - Create a global variable called PointKillDisp. (number=0)

    When Player collides with Astronaut, Add 1 to PointKillDisp.

    Every tick, Set (textbox) text to "Points: " & PointKillDisp.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)