Hi guys,
I'm developing a shoot 'em up game where if the player kills enemy, the enemy turns to a block (block is a new object replacing enemy - enemy is removed from the stage) and the player will be able to push the block around the level.
For some reason, I can't seem to setup the collision on the new block object that appears on the stage, I using the same code structure/idea for bullet detection on enemy but doesn't seem to function. I was wondering if anyone would know what I'm doing wrong or any suggestions to fix/work around? Here goes....
I have 3 classes/documents -
Block Class - Properies for the block object
Main Class - logic and core features of the game
Collision Class - Collision properies and setup
- Block Class -
- Main Class -Code:private function onEnterFrame(event:Event):void { MovieClip(parent).checkCollisionWithPlayer(this); }
I'm using the Collision.block(block, player) method call using the Collision class/doc, this works fine with collision between player and enemy, not why for this new object: block as shown below:Code:function checkCollisionWithEnemies(bullet:MovieClip) { var block:Block = new Block(); block.x = enemy.x; block.y = enemy.y; { if (enemy.meter.width < 1) { enemy.stop(); swapProperies(enemy,block); removeChild(enemy); enemy = null; addChild(block); } function checkCollisionWithPlayer(block:MovieClip) { if (player!= null) { Collision.block(block, player); }
- Main Class -
The only difference is that it's within a different function of onEnterFrame instead of heckCollisionWithPlayer, surely that shouldn't make a difference?Code:function onEnterFrame(event:Event):void { if (player.hitTestObject(enemy)) } Collision.block(player, enemy); }
Anyways any help or suggestions would be greatly appreciated.
Thanks
Jonesy


Reply With Quote