Help picking up and tossing enemies

Alright, Kirupa… I need your help on this… I’m trying to make it so the main character can pick up enemies and toss them to inflict damage both on the tossed enemy and on the targetted enemy…

Here’s the game thus far…
http://baiwanfuong.notix.net/omq.htm

If any of want want to see the FLA… please tell me how to attach it… I only know how to upload it and then link to it…

Thanks…
-chen Baiwan

Well? Can anyone help me?

Well that game is really wierd lol :stuck_out_tongue: I dnno if the drag enemies part is further along or not. As for code to pick them up with you could put something like this in an enemy:


onClipEvent (enterFrame) {
     this.onPress = function() {
          this.startDrag();
          throwing = true;
     }
     this.onRelease = function() {
          this.stopDrag();
          //add some kind of code for acceleration
     }
}

Your also going to need some type of formula for acceleration in throwing them. Then for a hitTest method you could use something like:


for (var i=0; i<maxEnemies; i++) {
     if (this.hitTest(_root["enemy" + i])) {
          if (_root["enemy" + i].throwing) {
               trace("enemy hit by thrown enemy");
          }
     }
}

I dnno maybe thatll work, im probably just dumb :p:

I don’t know about your idea of picking enemies up… but I like your idea of throwing them…

The game doesn’t use a mouse after all…


for (var i=0; i<maxEnemies; i++) {

What does this do? Does it mean Any number up to the max number?

Yeah, I didnt even think about the mouse when I wrote that. I was thinking along the lines of the game castle defense or something :stuck_out_tongue: In your case maybe you could try something like:


throwEnemy = new Object();
throwEnemy.onKeyDown = function() {
	if (key.isDown(Key.SHIFT)) {
		if (_root.hero.hitTest(_root.enemy)) {
			if (!_root.hero.throwing) {
				_root.hero.gotoAndStop("pick_up"); //frame label where hero is holding hands up to hold enemy
				_root.enemy.gotoAndStop("pick_up"); //frame label where enemy is rotated to be picked up
				_root.enemy._x = _root.hero._x;  //change x/y values to make enemy rest on hero's hands
				_root.enemy._y = _root.her._y + 50; 
				_root.hero.throwing = true;
			}
		}
	}
}
throwEnemy.onKeyUp = function() {
	if (key.isUp(Key.SHIFT)) {
		if (_root.hero.throwing) {
			_root.hero.gotoAndStop("throw");  //at the last frame of throw change hero.throwing back to false
			_root.enemy.gotoAndStop("throw");
			//add whatever else code to make him throw
			//hopefully this helps some how :P :P :P
		}
	}
}
Key.addListener(throwEnemy);

Hopefully that helps in some way lol. That would be used in main frame potentially.

Thank you for your help… however i have decided NOT to include tossing enemies in my game… but I have still been able to use some of that code you just taught me… Again…Thank you!