Hi, I have this shooter where this crab mc follows your mouse and whenvever you click it shoots a bullet from the mouse. There’s a blue button in the middle of the movie that allows you to generate targets by the duplicate movie clip function. Now when you fire a bullet though, a target just disappears without the bullet Hittesting at all with any of them! What is wrong??? Also is there a way to just have the targets to constantly duplicate independently without having to click a blue button to respawn them???I really hope someone can fix this. This problem has been plaguing me for over a month!!!Thanks in advance :).
Fargate -
Hey! I read your post and opened your fla. I have never really gotten a grasp on hitTest nor have I ever tried to make a game. So, I made this game. It’s still has some bugs, but for the most part works. Like the hitTest doesn’t always work??? I’m hoping that some of the game-rupa members can help me out with the bugs - cause I think I’ve changed everything around the best I can.
It should solve your problem though. Maybe…I hope!
Here’s the same thing with some sound. Thought it was neat. Maybe I’ll keep working on this. It’s kinda fun!!
wow thanks a lot that’s great…man now the only problem is the hittest bug…sometimes the targets don’t blow up when you hit them o_O…very odd…so close…lol…frustrating :p…anyone know what the solution could be???
You’re telling me. I sent a message to Clownstaples, he seems to know a lot about games. Hopefully he (or someone else hint hint) can figure it out…
lol…Ok thanks a lot Freddythunder.
im actually rather new to flash and games in general, however, this is a great page for all kinds of actionscript stuff
http://ericlin2.tripod.com/collision/bb5.html
basically he says that hittest cant be accurate 100% of the time because the motion is based on frames. If objects collide between frames, flash never catches it
the simplest solution is never let the bullet move faster than the width of the target, so it cant possibly “jump over” it
Freddy - the code in your file looks just fine all around.
How would you slow it down in the current .fla though…arg…could someone explain the code to me if it isn’t too much trouble. I don’t understand what controls the speed at which the bullets and the targets move at.
Fist off - Thank you Clownstaples for your time and looking over my code. Now that you said that, I do understand that article, but I don’t think that’s the problem with mine becase you can shoot one target 10 times in a row and it won’t blow up, but the next hundred do…However, by ‘bullets’ are streaming quickly. Thanks again!!
Fargate:
In your fla, the target is tweened back and forth. To slow that down would mean making the tweens longer. In mine, the targets are falling due to actionScript. One line of code:
[AS]
onClipEvent(enterFrame){
_x=40+Math.random()*450;
_y+=speed;
}
[/AS]
Think of enterFrame as code that loops indefinately. Each time, the variable speed (which is defined in onClipEvent(load); ) is added to the location of _y. For the bullets - it’s the same way. In the original movieClips actions, there is a line of code that I believe says:
[AS]
_y-=20;
[/AS]
If you make that 20 smaller, the increments will change each time Flash runs through that formula. If I confused you more, I’m sorry. Either way, check this out:
http://www.bit-101.com/tutorials/gravity.html
This is the tut that first taught me how to use object orientation programming. I reference it a lot. It should help you…
…Meanwhile, I’ll try to fix my game.
ok whoa I’ll try to work that out…and thanks for the source site…so if this frame thing isn’t why the hittest randomly doesn’t work sometimes…then what is!!!
EDIT: Ag a new bug…sometimes when you fire a bullet a target just dissapears ( pretty much randomly) before its hittested with anything! What is going on…
i havent seen a disappearing problem in your game on my computer. it sounds weird though
I dunno…this is going to drive me insane lol…ah well you can’t expect to learn flash in a day ;).
EDIT: I discovered that this disappearing problem on occurs for the first couple seconds of gameplay…then oddly it just fixes itself…
Oh no no no! I’ve had it happen for a couple targets in the beginning, or not at all, or halfway through play. I have no idea why it’s doing that. I figured it would be something wrong with a removeMovieClip() action, but the target doesn’t have any. I agree - it’s very weird…But it’s still fun to play! (I have a record low entertainment value - you will have to excuse me). Well, maybe someone will tell me what I’m doing wrong, cause now it’s bugging me…Grrr…
lol it’s bugging me too…It’s good nonetheless. How would I add a score to that…I’m gonna try and add a health component tommorow…I think I may know how…
i know why it disappears sometimes
duplicateMovieClip(“bulllet”
is replacing some of the
dyplicateMovie(“work”
items
you have to either
- put the bullets into a separate movieclip instead of _root
- pick a maxnumberof bullets and modify i++ to loop around to zero after the max, then change k to be k+maxNumOfBullets
basically when you create a “work” and you give it a level based on k
if you ever put a bullet into the level with the same number, it replaces the “work” that was there, so you can either separate them into different clips, or move the k level numbers up a 100 or so (k+100), and stop the bullets from ever reaching i=100
just had a thought.
you should also add a line that says
if(_y > Stage.height)
this.removeMovieClip();
in the target code so they dont just fall forever when you miss them
You are correct. As soon as I wrote my last post I thought to myself (self) Where do those missed movieClips go. They do stop on an empty frame in the timeline, but I guess it does still exist, right? Either way, I’ll throw that it - might make a difference with the bugs…maybe - Doesn’t make much sense, but niether do the bugs…(-:
lol I’m confused…
If you look at the fla…everything there is a movieClip, even when you shoot the red circles (when it works, that is) that movieClip still exists in the computer’s memory. When you remove it, it doesn’t clog any memory up - basically, the computer can forget about it. You use a line of code removeMovieClip to tell the computer to forget about objects - that’s all. All this stuff can be very confusing, but a lot of the things we’re going through are not basic. Stick with it though, you’ll get it, I have faith!!
ok thanks…so are you saying that this remove movie clip thing will fix the bug or what exactly?