18 Replies Latest reply on May 7, 2011 1:56 PM by Kanped

    Spawning multiple instances of a sprite (firing bullets).  Help needed.

    Kanped

      Hello there.  I'm currently trying to make a game in director 11.5 for a University project.  I've decided to make a scrolling space shooter but I've run into a problem.  Any tutorial I've found has created a limited 'bank' of bullets to fire, only allowing a certain number on the stage at any given time.  What I need to do is to leave a single bullet sprite off the boundaries of the page and essentially copy it and it's lingo behaviors to spawn another instance of the bullet on the stage when the player fires (using the left mouse button in this case).  I also need this copy to be deleted entirely when it collides with an enemy or leaves the boundaries of the stage, otherwise the game will just run slower and slower as more shots are fired.

       

      I have heard that this is possible using the puppetSprite() method but the API doesn't shine much light on the issue and neither has literally hours of google searches.  If anyone can let me know any method of doing this, I'd be very grateful.

       

      On a related issue, when fired the bullet will need to intsect the location of where the mouse cursor was when the bullet was fired and then continue on a linear path.  I've worked out a method of doing this but it isn't very effective or efficient (the speed of the bullets would be determined by how far away the mouse cursor is from the players ship and I think there's probably a less calculation intensive method for doing this) and as I can't spawn the bullets as of now, I really don't know if it will even work.  If anyone has any advice on how to better implement this mechanic, again I'd welcome your input.  Thanks in advance.

        • 1. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
          jchunick Level 2

          -- start of main script, movie script named "main script"

          on startMovie

            _movie.idleHandlerPeriod = 0

          end

           

          on mouseDown

            bullet = script("bullet script").new()

          end

          -- end of movie script
          -- start of frame script, frame script named "frame script"
          on exitFrame me
            go the frame
          end
          -- end of frame script
          -- start of bullet script, parent script named "bullet script"
          property bulletSp
          property minY
          property pObjTimer
          on new me
            -- create sprite
            -- find an empty channel starting at the topmost channel
            cnt = _movie.channel.count
            repeat with i = cnt down to 1
              if sprite(i).member = (member 0 of castLib 0) then
                -- make sprite
                bulletSp = channel(i).makeScriptedSprite(member("bullet"), _mouse.mouseLoc)
                bulletSp.scriptInstanceList.add(me)
                minY = -(member("bullet").height)
                -- start the bullet moving
                pObjTimer = timeout().new("bullet" & i, 3, #moveBullet, me)
                exit repeat
              end if
            end repeat
            return me
          end
          on moveBullet me, _objTimer
            bulletSp.locV = bulletSp.locV - 1
            sendAllSprites(#collisionTest, me)
            if bulletSp.locV <= minY then
              me.destroy()
            end if
          end
          on destroy me
            pObjTimer.forget()
            channel(bulletSp.spriteNum).removeScriptedSprite()
          end
          -- end of bullet script
          -- start of collision test script, behavior script named "collision script"
          on collisionTest me, _spOrg
            if sprite(_spOrg.spriteNum).intersects(sprite(me.spriteNum)) then
              sendSprite(_spOrg.spriteNum, #destroy)
            end if
          end
          -- end of collision test script
          1. Paste the "main script" into a movie script member and give it the same name.
          2. Double-click on frame 1 in the frame script channel and past the frame script into it.
          3. Create a new script, set it to a Parent script in the Property Inspector and paste the bullet script into it. Name it "bullet script"
          4. Create a new script, set it to a Behavior script in the Property Inspector and past the collision test script into it. Name it "collision script"
          5. Create a bullet image and make sure the registration point is set so that it's at the top point of the bullet. Name the member image "bullet".
          6. Create some rectangle shapes toward the top of the screen and then drag 'n drop the "collision script" on them.
          7. Press the Play button and move the mouse around the stage while clicking the left mouse button to fire the bullets. The bullets will be destroyed when they get to the top of the stage or when they hit a rectangle.
          8. Study the scripts. If you need the code commented, or a more thorough explanation/walk-through of what's going on in the code then let me know and I'll give it.
          • 2. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
            Kanped Level 1

            That's fantastic; really, thank you.  It's much more than I was expecting from this. There's a few methods in there I've never heard of before (if my lecturer had mentioned that 'makeScriptedSprite()' exists, I may have gotten further) but I can see how they work and I'm sure I'll be able to comment it myself.  Well, actually, I have to since if I just took your code as is, that would actually count against me as plagarism and my work may not be accepted (I've been using the java-style syntax up to now, so I'll use for loops instead of repeat with etc.).  This is exactly what I needed, though; a working script with the correct method calls to show me how to go about doing this because Lingo has so much functionality that we were simply never told about; the classes were specifically geared towards 'duck hunt' style games but I just wanted to do something different and honestly, without this I would have given up and made a duck hunt game.  So, thank you.  I have a fairly limited skill set but if for whatever reason you need any help with audio engineering, fighting game strategy or poker, I'd be happy to return the favour.

            • 3. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
              Mike Blaustein Level 4

              Just a small point here, but makeScriptedSprite() does exactly the same thing as puppetSprite.  The syntax is slightly different and there is the additional location parameter, but they are pretty much equivalent.  If your teach, for whatever reason, wanted you to use puppetsprite, you can use it instead.

              1 person found this helpful
              • 4. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                jchunick Level 2

                I should add this little change:

                 

                on moveBullet me, _objTimer

                  bulletSp.locV = bulletSp.locV - 1

                  _movie.updateStage()

                  sendAllSprites(#collisionTest, me)

                  if bulletSp.locV <= minY then

                    me.destroy()

                  end if

                end

                 

                adding the updateStage() call helps to update the bullet on the stage when it's locV value is changed (ie. it forces a stage redraw).

                 

                And here's a bit more explanation to it all:

                1. The Movie Script - this contains the single handler event, on mouseDown, which creates a new instance of the bullet script every time the left mouse button is clicked in the projector. Setting the idleHandlerHeriod to zero ensures as much consistency between timeout calls to the timeout handlers. The on idle handler with the sleep function is used to keep CPU use to a minimum, otherwise Director tends to hog the CPU to ensure best performance for multimedia heavy projectors. This DOES REQUIRE including the UIHelper Xtra which can be added from the menu, Modify --> Movie --> Xtras... --> click Add... button and select the UIHelper.x32 xtra.

                 

                2. The "bullet script" Parent Script - this creates a new instance of the script when called from the mouseDown handler in the movie script. It also creates a new sprite, sets the "bullet" member to that sprites and sets it's position to the mouse location. As well, it then adds the "bullet" script as an instance to the newly created sprite. The reason I have set the script to the sprite is for the purposes of referencing the sprite number in the collision script that's set as the 'me' parameter in the sendAllSprites() broadcast call. Lastly, it set's a new timeout object to move the bullet and update it's position on the stage. When the bullet reaches the top of the screen or intersects with an object it can collide with then the sprite is destroyed.

                 

                3. The "collision script" Behavior Script - This collision detection mechanism is the easiest way to figure out if your bullet sprite instance has collided with a collidable object. How it works is simply, in this case, the "bullet" script sends out a general broadcast message to all sprites, and the ones who have the #collisionTest handler will receive that message. Because we are sending a reference of the script as a parameter, the collision object's script can test to see if the sprite has intersected with it and if it has, then it can directly call the "bullet" sprites' script to tell it that there was a collision and to destroy itself.

                 

                That should give you enough detail to add where you need to such as sound effects, graphic effects, scoring, etc.

                 

                 

                • 5. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                  Production Monkey Level 3

                  Do you really need to use "UpdateStage()" ?   Because if you have 20 bullets that are updated say 30 times a second then you will have 600 screen updates per second. That may create a performance hit.

                  • 6. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                    jchunick Level 2

                    That's a good point. I added it in after realizing that I had forgotten that the timeout handler call will not force an update so although it's changing the position of the bullet, that update is not happening on the stage until the frame is redrawn. The updateStage() should be removed and the tempo set in the score to something beyond 30 such as 120 or even higher. This will smooth out the bullet animation, but it won't speed it up, which is the point of using the timeout objects in the first place.

                    • 7. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                      Kanped Level 1

                      Would there actually be a notable difference between say, 60 fps and 120?   120 seems very high and will likely drastically change the speed and timing of elements already programmed (I mean, I can change a few variables to fix that so it's not a big issue).  I mean, any AAA console game I'm aware of runs at 60 fps and won't this force an increased load on the CPU anyway?  I think I'll try to experiment with the update method and the fps to find a balance; it doesn't really matter if it's a little choppy; the target machines are 5 year old Celerons with 1 gig of RAM so even if it runs nicely on my i5, I need to tone it down quite a bit for those machines.  I'll experiment and see what works, anyway.

                      • 8. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                        jchunick Level 2

                        Yes, it's always best to experiment.

                         

                        There are several reasons why I like to use timeout objects for animation:

                        1) The tempo and frames are tied to one another. Laying out sprites on the score for animation is convenient and much easier for people, in general, but becomes unweildy when building complex, dynamic games.

                        2) If you can set up a good system then it's quite easy to adjust the timeout objects' period to control the individual objects' animation speed.

                        3) Your resolution for updating the objects' position or other information (that doesn't need a stage update) is down to the millisecond and doesn't have to be affected by a redraw (update to the stage), which is costly, as has been pointed out. In fact, you can even call an updateStage() every 3rd or 4th call to the timeout objects' handler with a smartly set variable. I'll leave that up to you to figure out.

                        • 9. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                          jchunick Level 2

                          Kanped wrote:

                           

                          Would there actually be a notable difference between say, 60 fps and 120?   120 seems very high and will likely drastically change the speed and timing of elements already programmed (I mean, I can change a few variables to fix that so it's not a big issue).  I mean, any AAA console game I'm aware of runs at 60 fps and won't this force an increased load on the CPU anyway?  I think I'll try to experiment with the update method and the fps to find a balance; it doesn't really matter if it's a little choppy; the target machines are 5 year old Celerons with 1 gig of RAM so even if it runs nicely on my i5, I need to tone it down quite a bit for those machines.  I'll experiment and see what works, anyway.

                          Any AAA console game is artificially capped at 60fps. PC games, which are more directly comparable, often are not artificially capped (although, it certainly does happen quite a bit). The point is that Director will just drop fames, if needed, afaik.

                           

                          That being said, I would definitely test early and test often - meaning that you should make sure you can do some benchmarking tests on the target machines.

                          • 10. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                            Kanped Level 1

                            The original script that you posted seems to be working very well.  I've modified it a bit but nothing to do with the framerate or update timer and it's running smoothly.  I have hit another snag, though and it's to do with that idea that I had for making the bullets move from the ship, intersect the mouse's location when it was clicked at continue on a linear path.  Here's what I've got

                             

                            on moveBullet me, _objTimer
                              pMousev = (gvShipLoc - _mouse.mousev)  / 20
                              pMouseh = (gvShipLoc - _mouse.mouseh) / 20
                              bulletSp.locV = bulletSp.locV - pMousev
                              bulletSp.locH = bulletSp.locH - pMouseh
                              sendAllSprites(#collisionTest, me)
                              if bulletSp.locV <= minY or bulletSp.locH <= minX then
                                me.destroy()
                              end if

                            end

                             

                            I made a minX variable since the bullets can also go off the horizontal axis of the screen.  I'm not really sure how it's working at the moment, given that the minY variable was created using the bullet's height (minX by it's length).  I don't really see how that ties into the containment of the screen's boundaries but since it should be possible to fire in all directions, will I need to make a maxY & maxX as well?

                             

                            Anyway, the idea was to subtract the location of the ship from both the X and Y co-ordinates of the mouse pointer, giving the mouse pointers location if the ship were 0, 0.  I would then divide both of these by a common integer (20 in this case), to be added in each itteration.  The actual interger itself should determine the speed of the bullet.  After 20 itterations, the bullet should be at the location where the mouse pointer was when the mouse was clicked but since the itteration does not stop at 20 (but rather continues every time a redraw is forced), it will continue on a linear path until it reaches the boundary and is destroyed.

                             

                            Well, that's the idea but what actually happens is that the bullet is created and is then instantly destroyed, with no error message.  I'm assuming, therefore that it's a fundamental misunderstanding of how the bullet is contained inside the boundaries of  the screen using the minY variable on my part, in that I've set it up to ALWAYS be outside of that range and instantly destroyed but I just don't see how it was working in the original script.

                             

                            One other thing, does the fact that I can't apply a definite sprite number to the bullets (since they go into the next free channel) mean that I can't use the 'intersects' function to determine collisions?  I'm getting 'handler not found in object' errors when I try to use member("bullet").intersects(sprite(whatever)) commands.  I was planning on using it to replace the enemy sprites with an explosion sprite and there's also another 'sheild' mechanic.  A ring appears around the ship when the right mouse button is pressed which should bounce the enemey bullets back (ebulletSp = ebulletSP * -1), which I think would be easier to implement with a simple line in the Sheild's script using the intersects function?

                            • 11. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                              Production Monkey Level 3

                              You want to work with objects not numbers which means using Points for locs and Sprite references and not sprite numbers.

                               

                              I feel that using a object manager object would make programming this a lot easier, cleaner, and more efficient. Rather than give a lecture on OOP and OOD, I took some of Josh's ideas like using a timeout object and wrote some scripts in my style to give you something else to boggle your brain.

                               

                              I tested these scripts but not thoroughly and I left plenty for you to do.

                               

                              I separated out the creation and control of "bullets" from the movement of the bullets. So, there is a behavior that does nothing more than move the bullet sprites and the control object handles everything else using a single timeout object.

                               

                              I suggest creating a new project to play with these scripts. Throw a bunch of sprites on the stage and attach the "Hitable Sprite" behavior to them, make sure you have a sprite named "bullet", and a " go the frame" behavior to loop on and you should be good to go.

                               

                              Note that where I set the velocity of the bullet sprites, that I use "100.0" instead of 20.  20 would be a very fast speed.

                               

                               

                              Here's the Parent script for the control:

                               

                               

                               

                              -- Bullet Control parent script

                               


                              property  pUpdateTimer  -- timeout object for doing updates
                              property  pBullets  -- list of bullet sprites
                              property  pGunLoc  -- location of the gun, ie the location where your bullets start at.
                              property  pRightBounds  -- right edge of the stage
                              property  pBottomBounds  -- bottom edge of the state
                              property  pZeroRect  -- used for intersection hit detection

                               


                              on new me
                                pUpdateTimer = timeout().new("BulletCntrl", 25, #update, me)  -- 25 milleseconds = 40 updates per second
                                pBullets = []
                                pGunLoc = point(300,550)  -- *** SET THIS to where you want your bullets to start at.
                                pZeroRect = rect(0,0,0,0)
                               
                                -- store stage bounds for later use
                                pRightBounds = _movie.stage.rect.width
                                pBottomBounds = _movie.stage.rect.height
                               
                                return me
                              end new

                               


                              on fire me
                                NewBullet = script("Bullet behavior").new(pGunLoc)  -- create new bullet sprite
                                if ilk(NewBullet, #sprite) then pBullets.add(NewBullet)  -- store sprite reference
                              end fire

                               


                              on update me, timeob
                                if pBullets.count = 0 then exit  -- no bullets to update
                               
                                -- update bullet positions
                                call(#update, pBullets)
                               
                                -- get list of sprites to test for hits/collisions
                                HitSprites = []
                                sendAllSprites(#areHitable, HitSprites)  -- the list "HitSprites" is populated by each hitable sprite.
                               
                                BulletsToDelete = []  -- list of bullet sprites to delete
                               
                                -- check if any bullet has hit a hitable sprite
                                repeat with Bullet in pBullets
                                  repeat with HitSprite in HitSprites
                                    if Bullet.rect.intersect(HitSprite.rect) <> pZeroRect then
                                      HitSprite.explode()
                                      BulletsToDelete.add(bullet)
                                      exit repeat  -- leave inner loop
                                    end if
                                  end repeat
                                end repeat
                               
                               
                                -- check if bullet is out of bounds
                                repeat with Bullet in pBullets
                                  Die = false
                                  if Bullet.right < 0 then Die = true
                                  if Bullet.left > pRightBounds then Die = true
                                  if Bullet.top > pBottomBounds then Die = true
                                  if Bullet.bottom < 0 then Die = true
                                 
                                  if Die then BulletsToDelete.add(Bullet)
                                end repeat
                               
                                -- remove any sprites that hit something or went off the screen
                                repeat with Bullet in BulletsToDelete
                                  Bullet.die()
                                  pBullets.deleteOne(Bullet)  -- remove bullet from list of active bullets
                                end repeat
                              end update

                               


                              on stopMovie
                                -- end of app cleanup
                                if pUpdateTimer.objectP then
                                  pUpdateTimer.forget()
                                  pUpdateTimer = void
                                end if
                              end

                              ------------------------------------------------------------------------------------------ ---------------------

                               

                               

                              The behavior for the bullets is:

                               

                               

                              -- Bullet behavior

                               

                              property  pMe
                              property  pVelocity
                              property  pCurLoc

                               

                              on new me, StartLoc
                                -- get a sprite
                                pMe = me.getSprite()
                                if pMe.voidP then return void  -- if not a sprite then give up
                               
                                -- setup this bullet sprite
                                pMe.puppet = true
                                pMe.member = member("bullet")
                                pMe.loc = StartLoc
                                pMe.scriptInstanceList.add(me)  -- add this behavior to this sprite
                               
                                -- set velocity
                                pVelocity = ( _mouse.mouseLoc - StartLoc) / 100.0  -- Note: magic number "20.0"
                               
                                updateStage()  -- need to update pMe.rect values
                               
                                pCurLoc = pMe.loc -- store current location
                                return pMe  -- Note: returning "pMe" not "me"
                              end new

                               


                              on getSprite me
                                repeat with CurChannel = 1 to the lastchannel
                                  if sprite(CurChannel).member = (member 0 of castLib 0) AND sprite(CurChannel).puppet = false then
                                    return sprite(CurChannel)
                                  end if
                                end repeat
                               
                                return void
                              end getSprite

                               


                              on update me
                                -- move bullet. 
                                pCurLoc = pCurLoc + pVelocity  -- add velocity to pCurLoc to maintain floating point accuracy
                                pMe.loc = pCurLoc 
                              end update

                               


                              on die me
                                pMe.scriptInstanceList = []  -- must manually clear this property
                                pMe.puppet = false
                              end

                              ------------------------------------------------------------------------------------------ --------------------

                               

                               

                              We setup everything in a Movie script:

                               

                              -- Movie Script

                               

                              global gBulletCntrl

                               

                              on prepareMovie
                                gBulletCntrl = script("Bullet Control").new()
                                the mouseDownScript = "gBulletCntrl.fire()"  -- route mouseDown events to the global object gBulletCntrl.
                              end prepareMovie

                               


                              on stopMovie
                                the mouseDownScript = ""
                              end stopMovie

                              ------------------------------------------------------------------------------------------ -----------

                               

                               

                              Finally since we are shooting at other sprites we need a script on them to interact with the bullets.

                               

                              --  Hitable Sprite Behavior

                               

                              property  pMe

                               


                              on beginSprite me
                                pMe = sprite(me.spriteNum)
                               
                              end beginSprite

                               


                              on enterFrame me
                                -- movie sprite
                              end enterFrame

                               


                              on areHitable me, HitList
                                HitList.add(pMe)
                              end areHitable

                               


                              on explode me
                                put "Boom"
                              end explode

                              --------------------------------------------------------------------------------

                              1 person found this helpful
                              • 12. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                                Kanped Level 1

                                OK, so you have an array to store all the bullets that have been created and another to store those that have fufilled the 'destroy' conditions, which will be destroyed on the update.  On the update, all sprites are called and any that are hitable (so, I need to give enemies an #areHitable symbol, right?  EDIT: Sorry, I didn't read the hitable sprite behavior properly, it will send itself there if that behavior is attatched, I see) are stored in another array, then you cycle through the bullet array along with the areHitable array to detect the collision using the ZeroRect variable, which is a 0 pixel rectangle to detect the actual intersection?

                                 

                                OK, I think I understand most of this.  I'd never seen ilk or scriptInstanceList before but the help file is actually pretty good (assuming you know the exact name of what you're looking for, anyway) and I see what you've done with them and how they work.  It's certainly far beyond what I've been doing up to this point (in Lingo, anyway) but I think I can get to grips with it and work from it.  Thank you.

                                • 14. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                                  Kanped Level 1

                                  Needed to tweak one thing slightly first off.  I have no idea why but according to the object inspector the variable pGunLoc was always 'void'.  The bullets are meant to come from the ship, which is moveable with the keyboard and therefore pGunLoc is variable.  So, I kinda cheated a bit.  I made an invisible rectangle and attatched this to it;

                                   

                                  on exitframe me
                                   
                                    sprite(me.spritenum).loch = sprite(4).loch
                                    sprite(me.spritenum).locv = (sprite(4).locv -23)  --the number 23 was trial and error
                                   
                                  end

                                   

                                  Since it will always be in the same channel, it allowed me to do this;

                                   

                                  on fire me
                                    NewBullet = script("Bullet behavior").new(sprite(11).loc)  -- create new bullet sprite
                                    if ilk(NewBullet, #sprite) then pBullets.add(NewBullet)  -- store sprite reference
                                  end fire

                                   

                                  And now, everything is as it should be.  Not exactly ellegant, but it works.  I'm still going to have a little play around with the code, of course.  It wouldn't be right for me to simply lift your code and pass it off as my own (possibly not legal, either) but I can confidently say that up this point, I've learned more in these few posts than I have from the past 3 months of study (and I promise that's not a reflection on my effort or attendence).

                                  • 15. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                                    Production Monkey Level 3

                                    You can legally use any code I post for what ever purpose you desire. However, making it your own for a class assignment is probably a good idea.

                                     

                                    I made pGunLoc a variable and passed it into the constructor of the Bullet behavior because I thought you might want it to change. Passing in "sprite(11).loc"  is fine.

                                     

                                    Lingo is really easy to learn. It just seems difficult at times because you can not buy a book that explains it, and the idiots that claim to teach it have no clue as to what they are talking about. If Macromedia or Adobe had supported Director the situation would be different.

                                    • 16. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                                      Kanped Level 1

                                      OK, I've been making some good progress and it's starting to come together but I have one major problem remaining.  I'm using code like this to move from one level to another;

                                       

                                      on exitFrame me
                                        if sprite(8).loch = 900 then
                                          _movie.go("Level2")
                                        else
                                          go the frame
                                          end if
                                      end

                                       

                                      So, sprite(8) is the enemy on the stage.  When a bullet hits it, it is sent to locH 900 and stopped from moving.  This actually works fine and moves onto the next level but when the new level starts, none of the sprites on the stage are affected by any behaviors attatched to them, it's like they have no behaviors attatched at all; don't more, aren't hittable.  If I stop the playback, skip to that level and press play, they all work fine.  I'm guessing it's to do with how puppets work, or the Timer object being used?

                                       

                                      Any ideas what could be causing this/how to fix it?

                                      • 17. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                                        Production Monkey Level 3

                                        When you Puppet a sprite or use a Scripted sprite you are telling Director to ignore all information in the score regarding these sprites.

                                         


                                        You might want to set aside say the first 200 sprite channels for sprites that are laid out on the stage and reserve the puppeted sprites for channels 200 and above, or whatever you need.

                                         

                                        on getSprite me
                                          repeat with CurChannel = 200 to the lastchannel  -- NOTE: start puppets at 200
                                            if sprite(CurChannel).member = (member 0 of castLib 0) AND sprite(CurChannel).puppet = false then
                                              return sprite(CurChannel)
                                            end if
                                          end repeat
                                         
                                          return void
                                        end getSprite

                                         

                                         

                                        Or,

                                         

                                         

                                        Tell all of the puppeted sprites to die before going to a new level.

                                         

                                        on exitFrame me
                                          if sprite(8).loch = 900 then

                                            sendAllSprites(#die)
                                            _movie.go("Level2")
                                          else
                                            go the frame
                                            end if
                                        end

                                        • 18. Re: Spawning multiple instances of a sprite (firing bullets).  Help needed.
                                          Kanped Level 1

                                          Well, I had to make it channel 30 (first unused channel) otherwise the bullets wouldn't fire at all for some reason and the send #die just randomly crashed the game (handler definition expected; not sure which sprites were having the problem with that one but as it turns out, it wasn't needed) but it seems to be working that way now.  Thanks again.