Something is wrong with this function.
public static function setBit(bitData:int, Bit:int, setTo:Boolean):int {
var newBitData = bitData | (int(setTo) << Bit);
return newBitData;
}
var bitInt:int = 5;
trace(bitInt);
bitInt=bitFunctions.setBit(bitInt,0,false);//Or true
trace(bitInt);
Running a trace on both sides for the number 5 shows no change… True or false.
This function seems to work properly in this code here…
var bitInt:int=0;
if (tileType == 1 || tileType == 2) {
//Set bit 0 to true for walkable
bitInt=bitFunctions.setBit(bitInt,0,true);
if (tileType == 1) {
//Set bit 2 to true for buildable
bitInt=bitFunctions.setBit(bitInt,2,true);
}
}
pathMapVec[Row][Col]=bitInt;
The first function only seems to work when the bit isn’t set to begin with…