My parent scripts look for open sprite channels within a given range, and pick the first free sprite channel to assign the object to, so basically it can support any number of instances of the object up to the amount the repeat loop supports. I create the balls like this: the ball_script is pasted below too repeat with x = 1 to 5 s=script("ball_script").new() -- create a ball object s.mysprite.loc = point(random(800),random(600)) -- set the location of the ball end repeat
If I type put s.mySprite in the message window I get a property not found error. Here is the ball script: **************************************************** property mysprite, Vspeed, Hspeed on new me repeat with x = 150 to 200 if sprite(x).puppet = false then exit repeat end repeat Vspeed = random(13)-7 Hspeed = random(13)-7 mysprite = sprite(x) -- first free sprite channel found in the repeat loop above mysprite.puppet = true -- link needs control of the sprite channel first mysprite.member = "ball" -- what does this sprite look like? mysprite.ink = 8 -- ink mode of the sprite (the actorlist).add(me) -- adds this instance to the actorlist return me end on stepframe me if mysprite.locV < 0 then Vspeed = -Vspeed end if if mysprite.locV > 600 then Vspeed = -Vspeed end if if mysprite.locH < 0 then Hspeed = -Hspeed end if if mysprite.locH > 800 then Hspeed = -Hspeed end if end repeat mysprite.locV = mysprite.locV + Vspeed mysprite.locH = mysprite.locH + Hspeed end ******************************************** Ok, to clarify, I don't need to do anything special to test for intersects between bouncing balls and stationary blocks on the stage? So I could put a nested repeat that tests all active balls against all active blocks for collisions simply by using the sprite(x) for the Sprite channel that the script put them in? If you see anything wrong with my OOP methods here please correct me, this is day 2 that I have actually been using OOP methods. I'm very familiar with Procedural so I can understand pretty much anything else. It's when we get into these objects that things start to get fuzzy, but I'm learning. Irvs OOP page helped me understand a lot, and the lab instructor at school made it a lot clearer. Thanks Jeremy -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Agustín María Rodríguez Sent: Wednesday, May 22, 2002 7:33 AM To: [EMAIL PROTECTED] Subject: Re: <lingo-l> OOP question DrEvil wrote: > I hope my question is a little clearer this time. Certainly it is :) So let´s answer it. This doesn´t depends on how was the sprite created (OOP, behavior, score). Once that the sprite is on the stage, you can check if intersects with another sprite normally. if sprite 8 intersects 12 then alert "they´re colliding" end if I guess that the problem is you´re not giving correctly the number of the sprites. I say I´m "guessing" because you don´t show us the code and which are the values of the variables you´re using. Try to use this to debug your code: put variableName So you´ll see where the error comes from. Or make it work hardcoded at the first moment and then use OOP, make it reusable, etc... Or answer this things and I´ll keep on trying to help: > s=script("ball_script").new() -- create a ball object What does this parets script do? It puts the sprite on the stage? > s.mysprite.loc = point(random(800),random(600)) Is mySprite a method that returns the number of sprite of the ball? What happends in the message window if you write: put s.mySprite? It returns an integer? > Syntax: > sprite(sprite1).intersects(sprite2) > sprite sprite1 intersects sprite2 What are the values of sprite1 and sprite2? > I don't know how to reference the objects in a conditional like this. > In pretty much all the variations I have tried I get "variable used > before assigned value" so I must not be referencing it right. That´s why I encourage you to stop using variables at the first moment. Make it hardcoded: if sprite 8 intersects 12 then And so on... do it with everything. Then go replacing that sprite numbers by variables. Use the debugger too and see with wich values are filled the variables. HTH, bye -- Agustín María Rodríguez http://www.StudioCerebral.com > Creative Roaster > Agustín [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!] [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]