About remembering the coordinate of respawn

Get help using Construct 2

Post » Sun Dec 04, 2016 12:26 am

So I have a sprite that will move when activated. When being moved, the instance variable "Counter" will activate , and after certain value, will respawn the object at the previous coordinate.
What is the best method of doing this ? I've tried to put 2 instance variables that store the value of the sprite coordinate, like "thisX" or "thisY" = coordinate.
But it doesnt always work. I dont understand how to differentiate trigger of a specific /individual object with object instance (class). Anyone can help me ?
B
7
S
1
Posts: 16
Reputation: 409

Post » Sun Dec 04, 2016 7:39 am

can you post your script?
Image Image Image
B
42
S
22
G
15
Posts: 372
Reputation: 12,215

Post » Sun Dec 04, 2016 7:07 pm

If I understand what you mean, you are destroying your sprite before re-spawning it at the previous spawn point, so when you destroy it do you not lose your instance variables, maybe try using global variables for your initial spawn points, also have you tried using int() when you set your coordinates, I've noticed that fixing some problems for me before
B
12
S
3
G
2
Posts: 37
Reputation: 1,378

Post » Sun Dec 04, 2016 7:52 pm

If it is only 1 instance of a sprite, i would place an invisible object on spawn coordinates, make it spawn new ones.
B
33
S
18
G
27
Posts: 2,431
Reputation: 20,326

Post » Mon Dec 05, 2016 11:07 pm

Image

I'll try explain again. The player character can kick an object (like a sphere), which has a coordinate of (40,100). After kick, the object will moving forward (and activating its bullet behavior). After the object hit something, like a wall.
It will destroy the object, and start adding its Counter / TImer variable . After certain value (like 100), it will respawn the object in (40,100).

I somehow succeeded in my first try ,by putting 2 instance variables (in the object, every individual object on screen)that store the value of coordinate : thisX (40) and thisY (100). Somehow it works, but the result makes the object multiplying themselves (like rapid fire shot in shmups games) and sometimes the object doesnt respawn anymore.

I'm really stuck at this. Anyone can help me? Thanks in advance. :)
B
7
S
1
Posts: 16
Reputation: 409

Post » Tue Dec 06, 2016 9:43 am

So, if i understand right, the object will respawn at the position where it got kicked.
And on some time after a kicked object got destroyed.

Attach the timer behavior to the player.

Give the object an instance boolean 'kicked'. Set that boolean true when the player kicks the object.
Give the PLAYER two instance variables for the coordinates. Say 'kickX' and 'kickY'.
Set 'kickX' and 'kickY' on the moment of the kick.



Now

On object destroyed
Is boolean instance variable set 'kicked'
.... set the boolean to false
.... Start a player timer with a certain 'tag' for the time you need

On timer 'tag'
.... create object on player.kickX and player.kickY

Cycle starts over when the player kicks.
B
33
S
18
G
27
Posts: 2,431
Reputation: 20,326

Post » Tue Dec 06, 2016 11:29 am

Well, this can be achieved by many ways. As you desired, here is something similar.
https://www.scirra.com/arcade/tutorial- ... wner-13147
Image
B
104
S
23
G
17
Posts: 1,350
Reputation: 22,028

Post » Tue Dec 06, 2016 11:13 pm

I'll try this. Thanks. (I apologize for long reply as I dont have my own internet connection)
B
7
S
1
Posts: 16
Reputation: 409

Post » Thu Dec 08, 2016 7:10 am

Message: GUN can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
All right, I'll post my capx.
Press WASD to move ,and Z to push Spheres.

http://s000.tinyupload.com/?file_id=16238843444679084395

I think It doesnt seem right to place the timer in the Player. As each instances / objects of Sphere has their own timer, which if any Sphere getting kicked, the corresponding Sphere will start the timer and respawn after 50 secs/ counts.

It is a strange thing that I experienced that the kicked spheres dont respawn at all (my first try with the (-almost-) same script did the respawn stuff). And it seems that you cant trigger the respawning after a sphere is destroyed (the manual says that it will make the Construct to crash).



It seems that the other viable options is:
1. Using UID for each Spheres on screen (which I completely drawing blank about)
2. Using Array / Dictionary / XML to store the coordinate of every spheres (which I have little experience with, and more awkward way to do in Construct)

I am currently struggling with 100 events limitation, so I need to be very efficient at using every events.

What is the best way to overcome this ?
And should I repost this topic in a different title?
B
7
S
1
Posts: 16
Reputation: 409

Post » Thu Dec 08, 2016 7:11 am

Message: GUN can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
http://s000.tinyupload.com/?file_id=16238843444679084395
B
7
S
1
Posts: 16
Reputation: 409

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests