This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2009-11-23 13:05:09

TheSalamander
Scratcher
Registered: 2009-11-23
Posts: 16

Instances

Hi guys!

I'm new to scratch and was wondering if there is a way to have multiple instances of the same sprite and have them created or destoyed on certain events.

Currently for the bullets in my game I have 6 different sprites hidden underneath the bar at the bottom that will move to the position of the character's sprite when the space bar is pressed. It doesnt seem like a particularly efficient option as it currently has all of them existing and running through their scripts taking up processing power.

Then it came to the enemies' bullets and the fun begins! I have over 36 sprites of bullets which all exist all the time. They slow the game down big time despite the fact most of them dont need to exist all the time!

To see just how slow it is:
http://scratch.mit.edu/projects/TheSalamander/772012

If you download it though it isnt that slow... :S


Sorry if this isn't that clear  sad

Offline

 

#2 2009-11-23 20:34:07

Greatdane
Scratcher
Registered: 2007-06-05
Posts: 1000+

Re: Instances

Unfortunately, there is no easy way to clone sprites in Scratch. However, you can make a sprite stamp itself using these blocks:
[blocks]
<stamp>
<clear>
[/blocks]


The future belongs to those who believe in the beauty of their dreams.
        ~ Eleanor Roosevelt

Offline

 

#3 2009-11-23 23:44:19

mythcaptor
Scratcher
Registered: 2009-10-08
Posts: 9

Re: Instances

unfortunately the only way to have a lot of sprites is to have a lot of sprites. No sprite is ever created or destroyed by the code, so if you need a lot of enemies, you'll need a lot of sprites. Sorry  sad

Offline

 

#4 2009-11-23 23:46:50

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: Instances

I downloaded the project and the enemies don't seem to be firing. Hmmmmm.

If you think the forever blocks are slowing it down, try using broadcasts sometimes instead of forevers.


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#5 2009-11-24 13:03:38

TheSalamander
Scratcher
Registered: 2009-11-23
Posts: 16

Re: Instances

Shame about that  sad

Ah well...
I didnt actually know what on earth broadcasts were when I made it (This is my first scratch project) but am reworking the whole thing basing the bullets from a pool instead of 3 bullets per enemy.


The green ones don't fire
When the difficulty increases (over time) orange ones will appear which fire straight down
After a longer period the metalic ones arrive which shoot towards you

Offline

 

Board footer