Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sprites on the fly

Status
Not open for further replies.

twistedlogic

Technical User
Jan 10, 2002
35
AU
I have a completly empty channels and I want to load cast members into these channels 'on the fly' ie create sprites.

This is supposed to load the first 6 cast members into the first 6 channels and position them 30 frames vertically apart. It doesn't work, and nothing is being added to the stage.

on enterFrame me
i=1
repeat while i = 1 to 6
vVLoc = (50+(i*30))
sprite(i).member = member(i)
sprite(i).locH = 700
sprite(i).locV = vVLoc
end repeat

end


Do I need to create 'empty' sprites off stage, or is there a way to load sprites into blank channels.

thanks in advance
 
You could use this parent script to generate objects on the stage:

--|:: puppet sprites ::|--

property spriteNumber
property pSprite
global objectList
global pShoot

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

on new me

spriteNumber = trouveSprite()
if spriteNumber > 0 then
puppetSprite spriteNumber, true
sprite(spriteNumber).member = member("envelope")
-- sprite(spriteNumber).scale = 50
-- sprite(spriteNumber).locH = 17
-- sprite(spriteNumber).locV = 325
sprite(spriteNumber).ink = 1
-- sprite(spriteNumber).ink = random(36)
sprite(spriteNumber).scriptInstanceList.add(me)
return me
end if

end

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

on prepareFrame me

-- sprite(spriteNumber).locH = sprite(spriteNumber).locH + 3 --random(5)
-- if sprite(spriteNumber).locH > 500 then deleteMoi me


end

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

on trouveSprite

repeat with i = 8 to 50
if sprite(i).memberNum <=0 then return i
end repeat
i =1
return -1

end

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

on deleteMoi me

puppetSprite spriteNumber, false
sprite(spriteNumber).scriptInstanceList.deleteOne(me)
-- objectList.deleteOne(me)

end

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

on check()
-- if the mouseMember = me then alert &quot;Stay away from there!&quot;
-- put the clickLoc
end

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

on giveSpriteNum me

pSprite = sprite(me.spriteNum)
return pSprite

end


Whenever you need to make a new object, just say:
pObject = new(script &quot;whatever your naming the above script&quot;)

THis will create a new object on stage.

Mayuresh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top