# Help picking up and tossing enemies

**URL:** https://forum.kirupa.com/t/help-picking-up-and-tossing-enemies/62005
**Category:** Uncategorized
**Created:** [August 24, 2004, 2:40am UTC](https://forum.kirupa.com/t/help-picking-up-and-tossing-enemies/62005 "2004-08-24T02:40:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Chen\_Baiwan](https://avatars.discourse-cdn.com/v4/letter/c/e0b2c6/32.png) [@Chen\_Baiwan](https://forum.kirupa.com/u/Chen_Baiwan)
#### Post date: [August 24, 2004, 2:40am UTC](https://forum.kirupa.com/t/help-picking-up-and-tossing-enemies/62005/1 "2004-08-24T02:40:49Z")

</div>

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](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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 24, 2004, 1:03pm UTC](https://forum.kirupa.com/t/help-picking-up-and-tossing-enemies/62005/2 "2004-08-24T13:03:12Z")

</div>

Well? Can anyone help me?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 24, 2004, 1:53pm UTC](https://forum.kirupa.com/t/help-picking-up-and-tossing-enemies/62005/3 "2004-08-24T13:53:29Z")

</div>

Well that game is really wierd lol 😛 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:

```php

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:

```php

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:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 24, 2004, 2:19pm UTC](https://forum.kirupa.com/t/help-picking-up-and-tossing-enemies/62005/4 "2004-08-24T14:19:22Z")

</div>

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…

```php

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

```

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 24, 2004, 4:50pm UTC](https://forum.kirupa.com/t/help-picking-up-and-tossing-enemies/62005/5 "2004-08-24T16:50:42Z")

</div>

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 😛 In your case maybe you could try something like:

```php

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 25, 2004, 3:39am UTC](https://forum.kirupa.com/t/help-picking-up-and-tossing-enemies/62005/6 "2004-08-25T03:39:08Z")

</div>

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!
