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…
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:
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:
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:
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!