About remembering the coordinate of respawn

0 favourites
From the Asset Store
Try to remember the sequence of moving pumpkins. Reproduce it according to your memory.
  • 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 ?

  • can you post your script?

  • 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

  • If it is only 1 instance of a sprite, i would place an invisible object on spawn coordinates, make it spawn new ones.

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

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

  • Well, this can be achieved by many ways. As you desired, here is something similar.

    https://www.scirra.com/arcade/tutorial- ... wner-13147

  • I'll try this. Thanks. (I apologize for long reply as I dont have my own internet connection)

  • All right, I'll post my capx.

    Press WASD to move ,and Z to push Spheres.

    s000.tinyupload.com

    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?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You are right, best way gonna be an array. I did not expect a 50 seconds, and that the player will be able to kick others in the mean time (not mentioned). I try to make an example, when i got time.

    Thinking about an array that adds on the end. And reads the first index (every second), spawns if needed, and then deletes the first index. A dt corrected time is essential in this.

    One question, dont you need a grid move ?

  • Okay.

    I have an Azerty keyboard. WASD is hellish for me. Changed keys, but that should not be a problem.

    Made the kicking more simple.

    Added an array to manage the re-spawning.

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

    Hope this helps.

  • Grid move ? Do you mean locking a player's movement in 4 direction (when a player move upward, left and right direction are locked ?). I could do that but it will take over 25 events ( it is a 4 players game). The 100 events limitation is a hell. It takes over 50 events just for a perfect control.

  • I made the kicking 1/4 th of your code, and it can all be done even smarter.

    Seen that way, the 100 events limitation is a blessing. You got to outsmart it, to start with as beginner.

    Cant think of a better environment. : )

  • Just to illustrate my point.

    My previous capx had 13 events.

    This one has 15 events including a system to move precisely over the grid.

    And it corrects a logic flaw, where spheres returned to place of last kick, not to where they started.

    https://drive.google.com/open?id=0B1SSu ... l9sdTVNZEU

    You need the MoveTo behavior.

    behavior-moveto_t63156

    Hope this helps.

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