Hi all. I'm currently developping a strategy game with Director, and one of the things I've run into is that i want to update the number of units I have in a panel (on initial game setup) via 1) updating a text member that holds the number of units left to setup and copyPixeling the image onto the panel. This I've acheived except that since my text member image doesnt have alpha originally and the panel is semitransparent, a white (no matter the bckgrnd color I set for the text member) bounding box appears in the final result. I guess the way to go is duplicating the text member image and make it a 1 bit mask image then using the apropiate imaging lingo command (dont remember if it's copyPixels or another at this point). Imaging lingo is very interesting for me since normally I built all my aplications using the score directly (15 years exp with Director). This is my first game where I mostly rely on parent scripting and in some situations imaging lingo.
This is currently the handler that does the job. It: 1) stores the image of the text member "panelCount" 2) defines the destinatiion rectangle where it will be copied in the panel bitmap and 3) copies it (but as I said the correct alpha is missing).
on updateUnitsDisplay me
-- we retrieve the image of the text member that stores how many units left in the panel
bottomMargin= 20 -- distance from the bottom of the panel that we want the text to be
_left= (sprite(me.spriteNum).width- _textImage.width)/2
_top= sprite(me.spriteNum).height- bottomMargin- (_textImage.height/2)
_right= _left+ _textImage.width
_bottom= _top+ _textImage.height
destRect= rect(_left, _top, _right, _bottom)
pPanelMember.image.copyPixels(_textImage, destRect, _textImage.rect)
Your proposals and thoughts are welcome (specially good ones )
EDIT: I've said above that my textImage wouldnt have alpha originally. Well, i think that was wrong according to what I've found in he scripting dictionary under the image() section "When you create a new image object, the background color defaults to white (color(255,255,255)), and the alpha channel is completely opaque (color(0,0,0))."
On the other hand, the paramList in the copyPixels command should do it I think (a matte can be defined, also and ink mode for the copied pixels can be used although my first experiments have not worked yet).
I think I got it. The paramList in the copyPixels command has been enough to get rid of the white box around the text (using #ink: 36 which is bckgrnd transparent in it), the problem was that I was using the same white for foreground and background colors in the text member (been some time not using director and misplaced the false white I used to use in these cases in the color selector). Bottom line, dont use exact same color values for back and fore colors of the text member. I've observed also that using the alpha of the image (useAlpha= true) makes it well antialiased while not using the alpha does produces a bad image of the text (btw, the font of the text is an inserted text media element of course). I keep investigating