Spawn platforms evenly
davidsalomon
Member Posts: 136
Hello everyone, I am having trouble making my spawning platforms look evenly as they appear in the right side of the screen and move to the left. I don't want spaces to appear and I really need to keep the platforms to appear one next to the other because I will make a platform pattern image that will make it look as if it's a continuous platform.
I made a video to better explain my issues:
Hope you can help me out!
I made a video to better explain my issues:
Hope you can help me out!
Answers
If you run your project for a couple of minutes** you should see the space between the platforms increase.
** change 'game.Gamespeed -2' to 'game.Gamespeed -20' so you can see what is happening a little quicker.
. . . . . . . . .
But putting that issue aside for a moment, how have you calculated the width of each platform piece in relation to the rate at which they are spawned ? 1 second for the spawn rate seems like an arbitrary figure, the spawn rate needs to be related to the platform width and speed.
By the way, it really would be easier to use the Move behaviour but I can't manage to make a condition that if a platform is gone from the screen, how to spawn it again in the right side of the screen. I think once I saw a video of Tshirtbooth on how to re-appear a cloud in the background, I'll check that out.
Edit: couldn't make it work like the clouds as Tshirtbooth did
So . . . not an ideal system.
How to calculate speed in this context: scene width / desired time = 'speed' . . . .
So, if you want an actor to travel 568 pixels in 5 seconds it should be travelling at a speed of 113.6.
So if you were to use move you would make the speed 113.6.
If you were to use spawn every second then each platform would need to be 113.6 pixels wide.
If you want each platform to be a quarter of the width of the screen (you have 4 platform in your example) - then each will need to be 142 pixels wide, so the duration of your interpolation would need to be 4 (568 / 4 = 142) rather than the 5 you currently have.
When x position = XXX then destroy actor and spawn a new one righthand side of the screen.
Or . . .
When x position = XXX the change x position to the righthand side of the screen.
So the best solution is with the interpolate (with everything you told me) rather than any other solution?
The ideal way would be to move the camera to the right rather than move the scene to the left.
That way you are only worried about moving your actor to the right - rather than worrying about moving your whole game to the left.
But I am not expert on scrolling platform games, never made one, there are lots of people here who could probably offer you lots of good ideas . . . . .
Hope that someone with scrolling platform games helps me out too!
Moving the camera does not introduce these little gaps.
The answer is not in the platforms, is in the enemy spawns!
I want to spawn enemies and obstacles, I'll just give an effect/scrolling images to the platforms and make it as if my hero is moving forward!
And the enemies will just appear faster and move faster too.
This really is the most difficult way I can imagine achieving side scrolling action !
If score < 100
animate 12 fps
If score is >99
and
<200
animate 20 fps
etc etc
But generally theres 2 ways people would use to make a runner ... player moves with camera or player stays and the scenes moves in from the left just looping
If you could, you would need to increment the frame rate in small (but accurate) fractions to keep sync with the increasingly speedy enemies, but not only can the animate frame rate not be accessed, but even if it could it only increments in whole numbers - and even if you could access these whole number values they are inaccurate to the point of being largely ornamental.
eg:
30 fps on the animate fps slider plays at 23.5 fps.
29, 28, 27, 26, 25, 24, 23, 22 and 21 fps all play at 20.1 fps.
20 fps plays at 16.5 fps
. . . . etc etc
Which might lead you to creating your own timers using rules that check the game's clock (self.time / game.time) . . . . but honestly this is all getting a little insane ! you will end up with dozens of fixes and tricks and workarounds and animations and attributes and constrains (etc etc) - all to avoid simply moving the camera !
It's like he is trying to get from his house to the train station - and we are all offering workarounds and tricks and clever ideas as to how he can move the city passed his house so that eventually the train station will come to him.
Personally, as i've got a little bit of extra time off this xmas and to have a break from my main project i'm working on, i've started work on a runner. Only spent half a day on it but have most mechanics down. I went with the whole everything scrolling from the left and its all going ok at the moment.
: )
Don't report me though, I heard the punishment for such a cyber crime is every time I switch on my Mac, a photo of Jedward appears!!! I'm not gonna lie, I don't know if I cant take that man!