PDA

View Full Version : Chucking rocks...


ApocX
04-19-2002, 06:21 AM
I dunno if this is a "Newbie" question, but it seems like it should be fairly simple (and yet I can't pull it off...)

I have a very basic game starting, where the enemy (computer controlled) is on a cliff, throwing rocks at the player (player can only move on the X axis...I know, it's simple, it's my first flash project).

I've got the movement / boundaries and even decent collision detection setup, but I need to know how to move the rock from it's current X/Y to the players last known X/Y (the rock chucking source is stationary, the human will be running back and forth on screen)

Thanks for any help!

Billy T
04-19-2002, 06:52 AM
how are you making the rocks? duplicate movie clip?

you could do something like this

on the rock -

onClipEvent(load){
targetX=_root.player._x;
cX=this._x;
difX=cX-targetX;
}
onClipEvent(enterFrame){
setProperty(this,_x,cX-(difX/20);
}

and something similar for Y

cheers

ApocX
04-19-2002, 07:17 AM
Thanks, I'll give that a shot.

I'm VERY new to flash, so I've just made a rock into a movie clip symbol, and positioned it where I want it to fall / be thrown from. The rock would get thrown, break on either the player, or the ground, and then be redrawn back to it's origin to repeat the process.

ApocX
04-20-2002, 01:15 AM
Ack...I'm having a tough time getting this rock to be thrown.

To see what I've got so far (and to get a better idea of what the hell I'm talking about) go here:

http://www.apocx.com/jumpinjim_r2.html

Basically the character on the top right needs to be chucking that rock at the player on the left, last known XY.

Billy T: I tried what you suggested, and that resulted in the rock hovering over the players head...

Billy T
04-20-2002, 02:49 AM
if the rock is hovering in the air then set its target Y to 100 higher something

you will need to use duplicate movie clip - have you used that before?

ApocX
04-20-2002, 02:57 AM
Haven't used the duplicate movie clip before.

I'm kinda jumping right into the fire here...I should probably be learning the fundamentals, but the project needs to be completed, and the original designer is no longer around.

Any help / code you can give would be greatly aprreciated. Then, once it's done, I can sit back and wonder what the hell I did / how it works :)

Billy T
04-20-2002, 03:01 AM
its a lot to explain. does the guy throwing the rocks have to be animated?

maybe send me an fla with the graphics and if I get time I'll have a play - billy@tableau.com.au

cheers