ForumsProgramming ForumHelp in a flash sniper game

65 20201
manny6574
offline
manny6574
922 posts
Nomad

please help in my first proper game in flash. The problem is that when you shoot the man he dies but once he's shot and you shoot him again he comes back alive and you can shoot him again. also I don't know how to make ammo and i want to use it. another problem is i don't know how to make the bullet do a crack in the building if it is shot. the crack image is the 'crack' symbol in the library. if you'd like to take a look at the thing then here's the download:

.fla: [url=http://www.mediafire.com/?uzdzugoznm2]

.swf: [url=http://www.mediafire.com/?nmz1mjtwa3i]

hope someone can help. also, im a beginer so if you could explain the actionscript then that would help. thanks

  • 65 Replies
manny6574
offline
manny6574
922 posts
Nomad

for the building script is this what you mean:

on(press){
var createCrack = _root.attachMovie("crack","crack", _root.getNextHighestDepth(), _root.getNextHighestDepth());
createCrack._y = _root.aim._y
createCrack._x = _root.aim._x
}
onClipEvent(load){
cracks.push(createCrack); <it had to be inside an onClipEvent
}
onClipEvent(load){
cracks = [];
}

on the winning frame it has:
for(var i in _root.building1.cracks)
{
_root.building1.cracks[i].removeMovieClip();
}

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

No, put cracks.push(createCrack) right after you position it's x value. (And no, it doesn't have to be in a clipEvent, I tested this before I posted it).
And put the removeMovieClip() line of code on the last frame inside the man movieClip.

manny6574
offline
manny6574
922 posts
Nomad

Works!!!!

manny6574
offline
manny6574
922 posts
Nomad

i need it to show a mission fail screen if you kill a civillian and i did this i dont know what's wrong:

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

On the start mission 2 button, instead of going to the frame with the mission failed screen, go to the frame with the next level. And when you shoot a civilian gotoAndStop the frame with the mission failed screen, but if you shoot the correct guy, gotoAndPlay (or gotoAndStop) the "you beat level2" frame

manny6574
offline
manny6574
922 posts
Nomad

i did the crack in mission 2 and i changed building1 to bar,restraunt and wall and in the last frames of the people id id the remove clip. why doesnt it work now???

manny6574
offline
manny6574
922 posts
Nomad

i solved the cracks now but when i do a seperate fail and win frame and i do gotoAndPlay win then it goes and plays it does a flick of the fail frame because it just before it

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

You're going to the fail frame, instead goto 1 frame higher (or how ever many frames it is).

manny6574
offline
manny6574
922 posts
Nomad

thats what i did except when it going there it shows the fail frame for a fraction of a second (but long enough to see it clearly) and then shows the win screen

manny6574
offline
manny6574
922 posts
Nomad

i've solved it now so im ok at the moment

manny6574
offline
manny6574
922 posts
Nomad

sorry but i didn't solve it. btw the fail screen is just a movie clip so maybe you can make it invisible if civ(civilian death) == false.

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

Ya, just make it invisible in an onLoad function, then make it visible when you lose the mission

IIAOPSW
offline
IIAOPSW
4 posts
Nomad

i think i know a better way then dead=true

use binary. have his being alive represented by 1

then every time you shoot him, multiply his "being alive" variable by 0.

saves about 3 bytes

anyway,

heres what i did

on the man movieClip

on(press){
if(_root.alive==1)
{
_root.man1.play();
_root.alive*=-1
}
}

on the frame itself

var alive=1
stop();

gl with your game.

also please play my game
http://www.kongregate.com/games/IIAOPSW/defuse

manny6574
offline
manny6574
922 posts
Nomad

half worked:

onClipEvent(load){
this._visible = false;
}
onClipEvent(load){
if(civ == true){
this._visible = true;
}
}


its invisible when you win but its also invisible when you loose

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

I think your problem is that you aren't changing civ to true correctly. When a civilian is killed, do something like _root.failMission.civ = true; // or whatever your failed mission screen is called.

Showing 31-45 of 65