The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.36 / 5.00 33,851 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 12,195 ViewsIn the game I am making, there is a crosshair movieclip. The crosshair movieclip has a shooting animation and on the 2nd and 3rd frames of this animation there is an invisible square that acts as a bullet scan directly inbetween the crosshairs. Here is the script for the square.
onClipEvent (enterFrame)
{
if (this.hitTest(_root.bgk))
{ _root.attachMovie.this("bulletHole", "<new name>", <depth>, {_x:_root_.xmouse, _y:_root._ymouse});
}// end if
} // end of for
I am trying to make it so, when the rectangle hits the "bgk" movieclip in the main timeline, it creates a bullethole on the exact position of the square.
Here is the error message I keep getting:
Expected a field name after '.' operator.
Thank-you, also... if there is a better code that serves the same purpose, by all means please share it with me!
remove the this. in after attachMovie and actually specify a number in the depth (_root.getNextHighestDepth () would work)
At 12/29/09 05:20 AM, Yambanshee wrote: remove the this. in after attachMovie and actually specify a number in the depth (_root.getNextHighestDepth () would work)
Yeah ^ should work but i think he just used <depth>, etc just as a filler, as an example of wat hed put
Your problem lies in the line:
_root.attachMovie.this("bulletHole", "<new name>", <depth>, {_x:_root._xmouse, _y:_root._ymouse});
If you want to attach the hole to the _root layer, you just need to say:
_root.attachMovie(...);
If you want to attach it inside the crossheir, just say:
this.attachMovie(...);
Also, if you're looking to do either of those things, the _x and _y positions of the hole will be screwed up, due to the current scope you are in. Below, I have code that gets the local position of the invisible square (called "shot"), and transformed it into coordinates on the _root layer.
var numHoles:Number = 0;
onEnterFrame = function(){
crossheir._x = _xmouse;
crossheir._y = _ymouse;
}
onMouseDown = function(){
var hole = _root.attachMovie("hole", "hole"+numHoles, getNextHighestDepth());
var point = new flash.geom.Point(crossheir.shot._x, crossheir.shot._y);
crossheir.localToGlobal(point);
hole._x = point.x;
hole._y = point.y;
numHoles++;
}
Finally,
REMEMBER TO NEVER CODE ON MOVIECLIPS.
Okay sorry guys, I've decided to use a new code, I am new to this attachmovie stuff and it was getting really confusing for me, here is my new code:
onClipEvent (enterFrame)
{
var i;
if (this.hitTest(_root.bgk))_root.bull.dupl icateMovieClip("bulletNew", i);
if (i == 10) {
i = 0;
}
}
It makes A bullet hole, but that's it, only one bullethole. I want as many as 30 on the screen at the same time. Also, with this code, the bulleholes overlap everything on the main timeline, which is not what I want.
Help please and thank-you!
At 12/29/09 05:00 PM, benjadaninja wrote: onClipEvent (enterFrame)
{
var i;
if (this.hitTest(_root.bgk))_root.bull.dupl icateMovieClip("bulletNew", i);
if (i == 10) {
i = 0;
}
}
It makes A bullet hole, but that's it, only one bullethole. I want as many as 30 on the screen at the same time. Also, with this code, the bulleholes overlap everything on the main timeline, which is not what I want.Help please and thank-you!
-> You never gave the variable i a value.
-> You re declare i every frame.
-> i is never changed.
-> In AS2 clips on the stage in the IDE are exported with negative depths, that you cannot remove with removeMovieClip unless you use the swapDepths() method to change it to a positive index.
-> You say you want 30, yet the if statement restricts it to only 10 (If there was a i++ statement before it)
-> Look up every function/operator I've mentioned here:
swapDepths(), ++, duplicateMovieClip(), removeMovieClip
Although practicality beats purity.
Errors should never pass silently.
In the face of ambiguity, refuse the temptation to guess.
At 12/29/09 11:23 PM, Montycarlo wrote:
-> In AS2 clips on the stage in the IDE are exported with negative depths, that you cannot remove with removeMovieClip unless you use the swapDepths() method to change it to a positive index.
-> You say you want 30, yet the if statement restricts it to only 10 (If there was a i++ statement before it)
-> Look up every function/operator I've mentioned here:
swapDepths(), ++, duplicateMovieClip(), removeMovieClip
Thanks for the help, but I don't really understand what you are trying to say. I am kind of a noob at AS.
Could someone please explain it in greater detail?
Thanks
Am I the only one who thought the title was "Help with buttholes please!" for a few seconds?
Jezus this is hard, can someone please just give me an .fla with working bulletholes?
I know the idea of this is to teach me how to do it by myself, but I don't see that happening.
Bump
Sorry, I've tried all these codes and none of them work! Please help!
At 12/31/09 12:43 AM, benjadaninja wrote: Bump
Sorry, I've tried all these codes and none of them work! Please help!
You need to understand all these functions you're using. Don't just keep trying random things hoping to get the result you want.
Montycarlo and Archon explained why your code isn't working.
With your last code, the only things you need are, as Montycarlo explained:
-> You never gave the variable i a value.
-> You re declare i every frame.
-> i is never changed.
You declare i ever frame with a null value. (Or is it undefined?) It doesn't have a value, and it will always be like this. Just make i increase in value, and move the declaration of it outside the enterFrame event.
k guys I am I doing it right? I tried to specify everything like you guys mentioned to do:
onClipEvent (enterFrame)
{
var bulletHole;
if (this.hitTest(_root.bgk))_root.bulletHol e.duplicateMovieClip(_root.bulletHole1, 30);
_root.bullet._x = this;
_root.bullet._y = this;
if (bulletHole == 30) {
bulletHole = 0;
}
But it still doesn't worrrrrrrkkk :(
I've fucking tried everything, so I am just going to email the .fla to one of you guys is that cool?
Here is a link to the file, I hope someone give me a working script out of this, or re-upload it with a working script.
http://www.badongo.com//?page=upload_s_c omplete&s=&msg=Click+here+to+download+yo ur+uploaded+other+file&url=http%3A%2F%2F www.badongo.com%2Ffile%2F19447989&url_ki ll=http%3A%2F%2Fwww.badongo.com%2Fdelete %2Ffile%2Fmz79cyj8%2F19447989&affiliate=
&thumb=0
Also, please refrain from stealing my movieclips...
Your code:
onClipEvent (enterFrame)
{
var bulletHole;
if (this.hitTest(_root.bgk))_root.bulletHole.duplicateMovieClip(_root.bulletHole1, 30);
_root.bullet._x = this;
_root.bullet._y = this;
if (bulletHole == 30) {
bulletHole = 0;
}
Is a mess. You did nothing of what was told to you. You just changed the name of a few variables... I haven't even downloaded your fla.
Let's take it step by step shall we?
First line, "var bulletHole;"
You just ignored what everyone said. Why are you declaring this every frame with a null value?? Move it out of the enterFrame event! And y'know, give it a value.
Second, what is this?
_root.bullet._x = this;
_root.bullet._y = this;
"this" equals the name of your movieClip. this._x equals its x value. Same for the way. It won't work the way you have it.
Third:
if (bulletHole == 30) {
bulletHole = 0;
}
Do you honestly expect bulletHole to someday equal 30? You can keep waiting, but it will never equal anything. Do you see anything in your code that makes it equal anything? I don't.
And it doesn't look like you're using this variable anyway...so what's the point?
Don't just keep throwing in stuff to see if it'll work. Please just look up how attachMovie works, and use it.
At 1/1/10 04:21 AM, 4urentertainment wrote: "this" equals the name of your movieClip. this._x equals its x value. Same for the way.
Meant: Same for the y value.
Sorry, wrong link. http://spamtheweb.com/ul/upload/010110/8 425_bullehole2.fla
this one's file size is smaller too
-You need to understand all these functions you're using. Don't just keep trying random things hoping to get the result you want-
To the guy who said this, I do this all the time :P
And it works, so why shouldn't you do this, I don't understand :(
At 1/1/10 11:00 AM, cheese123 wrote:-You need to understand all these functions you're using. Don't just keep trying random things hoping to get the result you want-To the guy who said this, I do this all the time :P
And it works, so why shouldn't you do this, I don't understand :(
because thats not learning, thats trail and error and grey hair
At 1/4/10 02:05 AM, benjadaninja wrote: last bump yo
Dude, you were given all the answers to your problems. Stop waiting for someone to do all the work for you.
Just have the bullet hole off the screen, so it can be duplicated
Then do this:
http://lmgtfy.com/?q=Actionscript+Duplic ate+Movie+Clip+
- There problem solved
CS3 version of file:
http://spamtheweb.com/ul/upload/090110/6 4705_bullehole3.fla
It's obvious you don't know what you're doing. You need to look up all these functions and things and make sure you understand how they work before you try to use them. Leave this for now and practice simpler things until you understand what you're doing.
At 1/9/10 08:45 PM, Neo-13 wrote: It's obvious you don't know what you're doing. You need to look up all these functions and things and make sure you understand how they work before you try to use them. Leave this for now and practice simpler things until you understand what you're doing.
I do have some understanding, I can get the holes to duplicate on a mousedown function, but not anyway else... which is what I want.
At 1/9/10 07:58 PM, benjadaninja wrote: CS3 version of file:
http://spamtheweb.com/ul/upload/090110/6 4705_bullehole3.fla
ahem
Bump for fucksakes, I just want bulletholes in my fucking game, I don't even want to learn anymore. It's been months, I've looked up tutorials, I've tried different codes, I've took baby steps... nothing works. For the love of god can someone please just look at the .fla and recommend a script?