Use Flash8 's bitmap to change clothes for people

Source: Internet
Author: User
Tags array

Many games have 2p characters, and the action is exactly the same as the 1p character, except that the color of the dress changes. So what do we do to change clothes? You might say that the 2p character is also painted as a set of pictures, which is certainly true, but usually an action game with a picture that can reach hundreds of pieces, Such an approach is really not worthy of approval.

Let's use BitmapData to make the problem simpler.

Here with the characters in the street bully "Red Crazy Ken" as an example, the following SWF, we point to the red Ken, his clothes will become blue color,

Click here to download the source file

Code:

Stage.scalemode = "Noscale";
Import BitmapData Class
Import Flash.display.BitmapData;
Import Flash.geom.Point;
Create a character
var kenbmd:bitmapdata = Bitmapdata.loadbitmap ("Ken", 1);
var kenmc:movieclip = This.createemptymovieclip ("KENMC", 1);
Kenmc.attachbitmap (Kenbmd, 1);
kenmc._x = 100;
Kenmc._y = 10;
Create a palette
var redarray:array = new Array (256);
for (var i = 0; i<255; i++) {
Redarray[i] = "0x00" +i.tostring (16) + "0000";
}
REDARRAY[0XF4] = 0X000000F4;
REDARRAY[0X95] = 0x00000095;
REDARRAY[0XDE] = 0X000000DE;
//
kenmc.onpress = function () {
Kenbmd.palettemap (Kenbmd, Kenbmd.rectangle, New Point (0, 0), redarray, NULL, NULL, NULL);
};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.