AllanR's Forum Posts

  • As usual, there are probably lots of ways to do it. It depends on how your game works, how long a typical run takes, how many enemies there are, do they exist for the whole run, do they spawn at the same point or do they randomly spawn, do they shoot at you, do you shoot at them, etc.

    ROJOhound's method records the Player's X, Y, Animation, Frame, and width every tick. If there isn't randomness to the game you could instead save the player's input and then have everything respond to the input in the same way to recreate what happened. There is also the Game Recorder object that can record a video of the canvas. I think that was meant to allow you to download the video, but it might be a way to play back exactly what happened without having to save all the things that move separately.

    The more that happens in your game, the more you have to save - and the more memory required to do that.

    One of my favorite games is Jetpack Joyride. At the end of a run they show you a snapshot from the run. Showing an instant replay is a lot trickier...

  • The example I made was obviously based on the file made by ROJOhound. He made the player a container and put the array in that. If you set up enemies the same way then each instance would have their own array. You would need a For Each Enemy loop to play back the recordings.

    the potential problem is if you kill an enemy, then the array will get destroyed with the enemy - making it impossible to play back. If enemies spawn and get killed regularly you will need a playback array that works differently than the player's array.

    if all the enemies exist at the start of the layout, and they don't die, then their recordings would line up with the player and play back correctly. If enemies spawn after the start, then they would have to use the frame counter from the player so that their recording will match up with the player.

  • you could share your file for us to look at. if may be something you changed that is causing the issue. or try running in debug mode to see if anything unusual is going on.

  • You can take a look at this sample I made long ago. Straight lines are pretty easy, if you want lines that curve it gets a lot trickier.

    you definitely don't want to be updating them every tick - only when you create them or need to move them.

    if you get stuck, it is easier for us to help if you post a sample project...

    https://www.rieperts.com/games/forum/Bezier_Curves.capx

  • you are using LayerToCanvas / CanvasToLayer correctly as far as I can tell.

    so the problem is either with the origin of the objects or something not being where you think it is...

    you will have to make a small sample file with the two layers and a couple of the objects so we can see what it going on.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • the example I posted saves the last 3 seconds, not the first 3 seconds.

    it takes 3 seconds for the array to fill up, but after that it starts deleting from the start of the array, and adds the latest player data to the end of the array. (so you always have the last 3 seconds of data)

    you could easily record the entire run, and only replay the last few seconds, or let the player decide how much to replay... you could also make a system to save the recording so that they can show other people, etc.

  • since "platform is on floor" is constantly true while the player is on the floor, that event constantly executes - which will make the animation start over and over again (never getting past the first frame). you need to add a trigger once, or another condition checking if it is not already playing the attack animation.

  • once you get to the end of the array there wont be any data to position the replay sprite with. so it will be setting its animation, frame and position to nothing. you want to stop playing the replay when it gets to the last entry in the array. (which will be array.width -1)

  • to record only the last seconds you just have to start deleting elements from the array once it has reached the desired playback length.

    every new frame is added to the back of the array, so you need to pop the first element in the array to remove that.

    this will help prevent the array from getting massive if game play goes on for a long time.

    if the player manages to die in under 2 seconds, you can calculate how long to show the replay layer by taking the width of the array, divide by 60, and multiply by 2 (since you are playing back at half speed).

    if you want more than just the last 2 seconds, you can set a variable to how long the array should be, and then use the method above to calculate exactly how long the replay will take to play back. In my example I record the last 3 seconds...

    https://www.rieperts.com/games/forum/slowmo2.c3p

  • here is a sample of ROJOhounds file that plays back at half the speed (although the new player sprite continues to record at the normal rate.

    if you change the slowfactor variable to 3, it would play back at 1/3 the normal rate. This doesn't use dt so it assumes game plays at a steady 60 frames a second...

    https://www.rieperts.com/games/forum/slowmo.c3p

  • your game is still running at 60 frames a second, but with a time scale of 0.5 it just updates things less often (things that are aware of the time scale) even though each tick happens at the normal speed.

    the playback from ROJOhound's file updates the sprite position every tick, so it is still moving at the normal speed. You would have to "play back" every entry in the array twice to make the sprite move at half the speed.

    if your game doesn't maintain 60 frames a second, then you may need to save dt as part of each entry in the array and then calculate exactly when each play back frame needs to be displayed.

  • I was thinking this was a good one for ROJOhound! :)

    that works nicely... we don't need to limit the speed because the 8Direction behavior does that automatically. it settles into an orbit around the target.

    I have a feeling oosyrag might want the sprite to converge on the target - as if it has gravity.

    how would you make the orbit shrink so that the sprite converges on the target?

    https://www.rieperts.com/games/forum/orbit3.c3p

  • are you using scale outer? when you do, the top left corner of the screen may not be 0,0. That is why oosyrag was asking about using viewport top and left.

    also, when using Touch.X and Touch.Y you can specify the layer to read from Touch.X(Buttons_Steal) Touch.Y(Buttons_Steal)

    that will eliminate any parallax trouble.

  • your array only allows for x values between 0 to 5

    and y values between 0 and 1

    and z values between 0 to 5

    you have height and depth values reversed.

    also, you have 8 columns and 8 rows (not 6, so your array should be 8 x 8 x 2).

    when you calculate simplified X and Y you subtract 1, so you get values from -1 to 6

    (you want 0 to 7, so don't subtract 1).

    and don't save the LevelEditor array to local storage inside the loop, do it once after the loops finishes.

    EDIT: I took another look and thought maybe you only want to save the middle 6 x 6 grid. The Save function selects all the Snow objects, and they are 8 x 8, so I guess their "Started" boolean should be set to true if they are not meant to be saved. If only the middle 6x6 tiles are to be saved then subtracting 1 would be correct.

  • ok, try adding trigger once to the Pixel_health <= 0

    that event is continuously firing, constantly restarting the animation to frame 0... until the first time it hits the wait 3 seconds and restarts the layout.