I know, this has been suggested countless times, but I just wanted to give my view on the subject. This is how I think it would work.
[blocks]
Create instance( # )of[ Sprite ]at x: (0)y: (0)
[/blocks]
"#" Meaning the instance would be labeled with a number. The original sprite would be Instance 0. If you were to create an instance with a number label that already exists, then the one that exists would move to the provided position. "Sprite" is the sprite you want to make an instance out of. X and Y is the position you want it to go to.
[blocks]
Delete Instance( # )of[ Sprite ]
[/blocks]
The instances are labeled with numbers, so you could delete a specific instance of the sprite.
[blocks]
Delete Self
[/blocks]
This would delete only the instance it's put in, so you can't put it in the background.
If you put a script in a sprite, then it would apply in all instances. Say you were making a shooting game, then this would be the script to fire:
[blocks]
<when green flag clicked>
<set{ v }to( 1
<when[ space ]key pressed>
<create instance( <{ v }> )of[ bullet ]at x x of gun )y y of gun )
[/blocks]
And the script in the bullet:
[blocks]
<when green flag clicked>
<forever>
<change y by( 10
<if> <( <y position> <>> 180 )>
<delete self>
<end>
<end>
[/blocks]
Last edited by Kingdaro (2010-04-04 18:42:54)
Offline
That is an Idea that has greatly been needed.
It would be useful for 2d shooters (The bullets).
Offline
Well explained...
We are touching object oriented programming here... :-)
What about variables? This might need to create a distinction between global variables (seen by all sprites) and local variables (distinct, owned by each instance)...
Offline
Phi_Lho wrote:
Well explained...
We are touching object oriented programming here... :-)
What about variables? This might need to create a distinction between global variables (seen by all sprites) and local variables (distinct, owned by each instance)...
Good point. I say that the local variables would indeed be owned by each instance. And the instances would be treated as multiple sprites, just copies of the same object, and you being able to have any amount of instances you want.
Offline
Maybe also have a variable called instance number, so you could check something like
When green flag clicked
[forever]
move (instance number) steps
Offline