Many questions!

Get help using Construct 2

Post » Thu Jan 17, 2013 3:08 am

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.capxPhyvo2013-01-17 15:12:50
B
6
S
1
Posts: 40
Reputation: 917

Post » Thu Jan 17, 2013 3:11 pm

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.
B
6
S
1
Posts: 40
Reputation: 917

Post » Thu Jan 17, 2013 5:16 pm

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.Yann2013-01-17 17:18:30
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Thu Jan 17, 2013 9:22 pm

[QUOTE=Phyvo] 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[/QUOTE]


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.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Thu Jan 24, 2013 10:19 pm

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.
B
5
Posts: 55
Reputation: 585


Return to How do I....?

Who is online

Users browsing this forum: mercuryus, zenox98 and 15 guests