J.F78
J.F78

Reputation: 1

Scrolling Clone Sprites

I'm attempting to make a code in which I have a sprite act as the main terrain sprite (aka a tile) and have clones of that sprite stack on to the end of it, while maintaining the scroll code, which allows the x positions of the main sprite and the clones to change as the player pushes down on the "a" and "d" Key, While maintaining their proper positions in line. The issue I am having is that for some reason the third costume in my terrain doesn't seem to appear when its clone is created to act as the last tile in line.

I think the issue is that it's already created all the clones, but the first terrain block it clones off of spawns at the same time as the new ones.

By the way, Scrollnum determines the position in the line.

script

Upvotes: 0

Views: 478

Answers (3)

J.F78
J.F78

Reputation: 1

I completely forgot about this question but I did manage to figure it out in the and I thought I should post the answer considering that it may be of help to others.

Let me explain this code a bit, as shown in the image this uses a block instead of the repeat loop I attempted to use mainly due to the ability to use it more often as well as condense my code. The CloneX variable is refers to the tiles X positioning as a multiple in reference to the screen size. The equation when used looks like this: (CloneX * 480) + ScrollX. The TileX variable refers to the amount in which you want cloned.

This is how I ended up calling it. I ended up setting the costume to the one I needed for the level in order to start the generation of tiles. Then I initialized for the variables in the block]2

Upvotes: 0

Ethan JC Rubik
Ethan JC Rubik

Reputation: 204

I have had a similar problem, and it's possible that you are not using the right costume number. Try going one costume number down.

Upvotes: 0

Scimonster
Scimonster

Reputation: 33409

When your clone starts, it goes to the next costume, but since the base spirte's costume is always the first, the clones' will always be the second. You need to set the costume according to the clone ID. That variable (scrollnum) should be "for this sprite only", by the way.

set costume to ((scrollnum) + (1))

Upvotes: 1

Related Questions