Discuss Scratch

Cub56
Scratcher
1000+ posts

Help With Tree and Rock Clones In My Game

In this game there are lots of trees, rocks and plants that are clones. The game is scrolling (using the regular Scroll X and Y method) so whenever the items move off the screen they hide.

However, I've used clones for each of these items and it results in LOTS of clones being in the project at once all constantly going to a certain x and y position in relation to the “Scroll X and Y” of the player. Which can result in lag when even more are added.

The items can be chopped down so they aren't supposed to be visible if they have been chopped down until they respawn after a few minutes.

I need to find a way to:
  • Allow clone trees/rocks to stay in the appropriate positions on the scrolling map
  • Clones to delete when going off the screen
  • Clones to also re-create when moving back into an area where they can be seen if they have not been chopped down
  • When the tree grows back, it will show up when moving to the right place

Can anyone help? Thanks a lot!

Last edited by Cub56 (Feb. 13, 2018 19:52:54)


Check out Life Raft Survival, my new advanced sandbox survival game with crafting, building, transportation, weather events, tropical storms, and more!

In the game you're stranded at sea after a mysterious crash and must survive in an unforgiving tropical island environment collecting resources and crafting, in an attempt to finally be rescued.



Cub56
Scratcher
1000+ posts

Help With Tree and Rock Clones In My Game

Bump, help please

Check out Life Raft Survival, my new advanced sandbox survival game with crafting, building, transportation, weather events, tropical storms, and more!

In the game you're stranded at sea after a mysterious crash and must survive in an unforgiving tropical island environment collecting resources and crafting, in an attempt to finally be rescued.



PutneyCat
Scratcher
500+ posts

Help With Tree and Rock Clones In My Game

I looked at the Tree sprite. Couple of v. quick thoughts.

(1) You could try merging your two “when I start as a clone” scripts. Better to have just one, which doesn't do a lot of unnecessary work if the tree is hidden and off screen.

(2) You could try using your lists rather than the clones as the basic way to control things. If a tree goes offscreen, delete the clone and just use the list position to determine when to create a replacement clone.

Good luck.

Powered by DjangoBB