Struck with Endless Car Shooting game

Hi all,

I am very new to Cocos Creator. I am trying to create a car racing game. Firstly, I created one road prefab, 3 sprites. Now I want to dynamically create a road as the car is moving forward. I am using cc.instantiate(this.ground). But somehow my new road is getting messed. Can somebody help me in this regard? I am using Cocos Creator 2.4.3. Attaching the full code that I coded till now.

https://drive.google.com/file/d/1oOKWZU2ID0RSsLuAeJs116JJ9pdbK38U/view?usp=sharing

Please help me, as I am struck here since last few days.

Hey,
There are two bugs in the project that are causing this issue.

  • The roads in the scene have different LinearVelocity (two of them have -300 and two of them have -1000) make them all same.
  • The addRoad() method in Game.ts adds the road at y=2000, Add it to the location of the farthest road and you should have it fine.

Here is how i updated it.

    addroad(){
        var newground = cc.instantiate(this.ground);
        newground.setPosition(0,7020);
        this.node.addChild(newground);
    }
1 Like