|
Prev: Flash component
Next: Director based file browser
From: DaveGallant on 24 Jun 2008 11:56 I have several sprites located on the stage. These are puppeted sprites. Here is the code that I use to create them: [Q] c = GetNextChannel(#bitmap) -- get a new free channel gChannels.append(c) -- add it to our array so we can track used channels. sprite(c).puppet = true -- puppet the sprite sprite(c).scriptInstanceList = [] -- clear any scripts that may have been on this sprite from a previous use sprite(c).scriptInstanceList.add(new(script "clsCustomer")) -- add our character script. sprite(c).member = void -- remove any previous members. this is needed otherwise, you can get member problems. sprite(c).member = member(CustomerType & "_Walk_se_0001", CustomerType) -- set the member sprite(c).width = sprite(c).member.image.width -- set the sprite width and height to the new member size sprite(c).height = sprite(c).member.image.height sprite(c).visible = false -- make it not visible until we need it on the stage sprite(c).locH = -200 -- Set the starting location sprite(c).locV = -200 sprite(c).LocZ = gChannelStart -- Set the intial locz to a constant layer value - in this case, gChannelStart is = to 100 sprite(c).ink = 8 -- set the ink sprite(c).Initialize(c) -- Call a routine int he character to do all the stuff I need it to do that would normally be called on a begin sprite gCurrentLevel.pCustomerSprites.append(sprite(c)) -- add the sprite to our array of active characters [/Q] nothing overly special. GetNextChannel is a routine I wrote which tracks the channels I use when creating and re-using sprites. Anyway.... Every once in a while..... for some reason, no matter what I set the locz to, the sprite is "always on top" of all other sprites. There is code int he customer class to change it's locz depending on it state, position, etc. I was able to put a break point in the exitframe routine (where I am doing a locz check) and managed to find the following: - the locz of the sprite SAYS it's 20, however, sprites that have a locz higher than 20 are appearing behind the character - changing the locz in the message window, followed by an update stage has NO effect on the character sprite, but it does work for all other sprites on the stage. - I can toggle the visibility both on the score and through lingo via the message window. - as far as I can tell, directtostage is false. - some of the sprites are appearing behind the character are in a lower channel slot than the character (as they were created before the character) but where given a locz GREATER than the character to force them to be on top. - There is no 3D, flash, or anything special happening, except all the sprites are puppets and created using similiar code to the above. Question: What could cause the locz of a sprite not to work?
|
Pages: 1 Prev: Flash component Next: Director based file browser |