ForumsProgramming Forum[Need Help] Attaching movie clips (my weapons).. etc

115 37133
Voidcrystal
offline
Voidcrystal
138 posts
Nomad

Hello!

1.I need help with some scripting that i can't really do, i need to attach my weapon to the character, i have made the weapon and i can rotate it and here is the script:

onClipEvent (enterFrame) {

_rotation = ((Math.atan2(_root._ymouse-_y,_root._xmouse-_x)/(Math.PI/180))+90)
}

2.I would also like to make the buttons 1, 2, 3, 4, 5 as weapon buttons, as an example: 1: glock, 2: uzi, 3: mp5, 4: Sniper, 5. bazooka. But i don't want the people to have them all at the beginning, i want them to buy them for kills at the end of the level.

3. How do i make my enemies have more hp or less hp? And how to make the the weapons shoot faster and slower, more dmg and lesser dmg.

I know this is kinda much but this is all the things i don't really understand atm, thanks for reading and if you can help, please do.

  • 115 Replies
AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

Hehe, I ain't a pro, but I could figure this out, but if you want to then go ahead.

Here's my potential solution.
Delete code anywhere that has to do with making guns visible or invisible.

In the onLoad function of the mcMain class add:
this.glock._visible = true;
this.uzi._visible = false;
this.sniper._visible = false;
//make all other guns invisible
and if for some reason that doesn't work change "this." into "_root.mcMain."

before the functions make a var for each gun's availability
then in the enterFrame function add:

if(Key.isDown(49) && glockAvailable == true)
{
_root.mcMain.glock._visible = true;
_root.mcMain.sniper._visible = false;
_root.mcMain.uzi._visible = false;
//make the rest of the guns invisible
}
if(Key.isDown(50) && sniperAvailable == true)
{
_root.mcMain.sniper._visible = true;
_root.mcMain.glock._visible = false;
_root.mcMain.uzi._visible = false;
//make other guns invisible
}
//continue this process for each number for each gun

If you wanted you could also put the movement code here which would be similar to this:

if(Key.isDown(Key.LEFT) or Key.isDown(65))
{
_x -= 30;
}
if(Key.isDown(Key.RIGHT) or Key.isDown(68))
{
_x += 30;
}

this would work for moving left and right with arrow keys and WASD.

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

Wait, hair selection? I thought your problem was with the gun changing...

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

Nice! But where should i put jump and gravity? :P

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

yeah hair, eyes and body :P i want that too ^^

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

Jumping and gravity: (this may not be the most efficient way to do it, but it should work). Make a var for yspeed. Then in the enterFrame function add:
if(Key.isDown(Key.UP) or Key.isDown(87))
{
if(yspeed == 0)
{
yspeed = 30;
}
}
_y -= yspeed;
yspeed -= 0.5; // or however much you want it to decrease by per frame

and then do something along the lines of:
if(this.hitTest(_root.ground))
{
yspeed = 0;
_y -- //this is to make your character not sink into the ground.
}


hair eyes & body: Do you already have the selection process working?

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

yep i have the process working and i already have gravity i scripted :P, but i want to know where to put it hehe

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

Oh, well you put it in the enterFrame function of mcMain's class.

One way to do the hair selection thing is to create a variable for the type of hair. Then, when the player presses the button that starts a level, make all types of hair invisible then do something like:
if(hairStyle == 1)
{
_root.mcMain.hair1._visible = true;
}
if(hairStyle == 2)
{
_root.mcMain.hair2._visible = true;
}
// etc. for each hair style.

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

hairstyle == 1? :P you mean hair1

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

well happy new year, i gotta go to bed but i am going to test it out tomorrow, i might do something wrong now because i am sleepy :P

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

I was using hairStyle as a variable for which hair style your character has.

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

you can actually open flash and try the scripts out and test if they work while i am sleeping . Isn't that a good idea?
When you have solved the problem, then post them here ^^

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

Didn't I just solve the problem and give you the code?

plasmafish
offline
plasmafish
252 posts
Nomad

He's looking for a handout, and you're giving it to him.

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

handout :?

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

Sorry if i asked too much, i will have to fix it myself then :S

Showing 91-105 of 115