bitmapdata hittest bug (Error #2005) [Flash 10]
| Beiträge: 15 Registriert: Jul 2011
| 22.02.2012, 17:25
hi,
gelegentlich bekomme ich diesen hartnaeckigen Fehler:
ActionScript:1 2 | ArgumentError: Error #2005: Parameter 0 is of the incorrect type. Should be type BitmapData.
at flash.display::BitmapData/hitTest()
|
Das betrifft diese Zeile:
ActionScript:1 | if (player.bitmapData.hitTest(player.point, 255, tempUpgrade.bitmapData, tempUpgrade.point, 255))
|
Momentan komme ich da einfach nicht mehr weiter. Mein objekt (tempUpgrade) wird innerhalb einer manager-Klasse erstellt, d.h. es wird das Aussehen
definiert (spritesheet aus library-Klasse) und anschliessend wird das Spritesheet mit Hilfe einer CacheTileSheet-Klasse in entsprechend kleine Bildchen zerlegt so dass ich diese in einen Array schmeissen kann (die bitmapData-Daten werden fuer eine pixel-genaue Kollisionsabfrage benoetigt).
Das hier ist nicht der gesamte Code. Ich habe mal die Teile ausgesucht wo ich glaube dass der Fehler drin sein koennte (aber ich kann mich da natuerlich auch taeuschen.)
Bitte - kann mir da jemand weiterhelfen? Vielen dank.
hier wird das aussehen definiert
ActionScript:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | public function createUpgradeLook(type:int, cache:Boolean = false):void
{
if (type == 0) {//health
this._width = 256;
this._height = 64;
if (cache) {
imageBM = new Library.PowerUpHealth();
tileSheet = new TileSheet(imageBM.bitmapData, 32, 32, false, 16);
}
}
animationCount = 0;
animationDelay = 1;
cacheType = type;
_type = type;
if (cache) {
cacheSheet = new CacheTileSheet();//hier wird das spritesheet gesplittet
allocateCache(cacheType, cacheSheet.cacheSpriteSheet(tileSheet));
cacheSheet.tempCache = [];
imageBM.bitmapData.dispose();
imageBM.bitmapData = null;
}
}
|
hier wird gecacht
ActionScript:1 2 3 4 | private function allocateCache(row:int, cache:Array):void {
tileCache[row] = cache;
cache = [];
}
|
hier wird das Objekt generiert (mit all seinen entspr. Daten)
ActionScript:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | public function createUpgrades(xPos:Number, yPos:Number, speed:Number, life:int, level:int):void {
var tempUpgrade:Upgrade = new Upgrade(_xMin, _xMax, _yMin, _yMax);
var reverseAni:Number = randomRange(1, 2);
if (reverseAni == 1) {
reverse = false;
} else {
reverse = true;
}
var randomAni:Number = randomRange(0, 15);
currentTile = randomAni;
tempUpgrade.dx = Math.cos(6.28 * ((Math.random() * 360) - 90) / 360.0);
tempUpgrade.dy = Math.sin(6.28 * ((Math.random() * 360) - 90) / 360.0);
tempUpgrade._type = _type;
tempUpgrade.width = this._width;
tempUpgrade.height = this._height;
tempUpgrade.x = xPos;
tempUpgrade.y = yPos;
tempUpgrade.frame = currentTile;
tempUpgrade.animationList = tileCache[_type];
tempUpgrade.animationCount = animationCount;
tempUpgrade.animationDelay = animationDelay;
tempUpgrade.reverse = reverse;
tempUpgrade.bitmapData = new BitmapData(this._width, this._height, true, 0x00000000);
tempUpgrade.bitmapData = tempUpgrade.animationList[currentTile];
tempUpgrade.nextX = tempUpgrade.x;
tempUpgrade.nextY = tempUpgrade.y;
upgrades.push(tempUpgrade);
}
|
| |
| Ähnliche Beiträge zum Thema | |
|
Flashhilfe.de Flash Platform Tipps & Tutorials Flash Platform Andere Programmiersprachen Jobangebote Diskussionen
Flashhilfe News
Regeln & Bedingungen
|