On my game there is character creation, when creating a character you can choose it’s hair (along with other things…) you can change the hair color, and the hair design… It’s a bit hard to explain, so I’ll explain it a bit more after the code…
charBox.colorRightBtn.addEventListener(MouseEvent.CLICK, hairPlus);
var hairNum:int = 0;
var hairBitmap:hair_1_1 = new hair_1_1(1,1);
function hairPlus(event:MouseEvent):void{
if(hairNum == 0){
var hairBitmap:hair_1_2 = new hair_1_2(0,0);
hairBase.copyPixels(hairBitmap, rect, pt);
charBox.charDisplay.addChild(new Bitmap(hairBase));
}
hairNum++;
if(hairNum >= 1){
hairNum = 0;
}
}
hairBase.copyPixels(hairBitmap, rect, pt);
charBox.charDisplay.addChild(new Bitmap(bmd2));
charBox.charDisplay.addChild(new Bitmap(hairBase));
addChild(charBox);
var clicks:int = 0;
charBox.charDisplay.addEventListener(MouseEvent.CLICK, changePic);
function changePic(event:MouseEvent):void{
if(clicks == 0){
row = 1;
clicks++;
} else if(clicks == 1){
charBox.charDisplay.scaleX = 1;
charBox.charDisplay.x -= charBox.charDisplay.width;
clicks++;
} else if(clicks == 2) {
row = 0;
clicks++;
} else if(clicks == 3){
charBox.charDisplay.scaleX = -1;
charBox.charDisplay.x += charBox.charDisplay.width;
clicks = 0;
}
var rect:Rectangle = new Rectangle(96 * col, 128 * row, 96, 128);
var pt:Point = new Point(0, 0);
bmd2.copyPixels(bmd1, rect, pt);
hairBase.copyPixels(hairBitmap, rect, pt);
charBox.charDisplay.addChild(new Bitmap(bmd2));
charBox.charDisplay.addChild(new Bitmap(hairBase));
}
Now, there’s a box that displays the current character, and if you click the character it turns it to a different angle, so you can click to turn it one direction. (2-d isometric). When the character creation box it opened it starts with bitmap hair_1_1 then there’s a button to change the hair color. From this example it changes the bitmap being used to hair_1_2. That works, accept when I click on the box (charBox.charDisplay) to change the angle shown, the hair goes back to hair_1_1 orignally. This probably isn’t the best logic used to do this, so any help is greatly appreciated.
I need it to start at bitmap hair_1_1 then be able to change the bitmap resource that’s being used for the hair…