Be a Supporter!

New to actionscript...

  • 289 Views
  • 8 Replies
New Topic Respond to this Topic
sonic180
sonic180
  • Member since: Feb. 4, 2006
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
New to actionscript... 2008-12-11 11:04:10 Reply

Can someone help me with this? I am having problems with a score system... I have been looking over many many tutorials found on google, and I found one that helped a little... So here is the script and everything

I have two frames, the first one is blank with some code setting the score var, the second frame has the character and the collectible, I have everything working right, except... If I add more then one collectible, the the copy does not work... Only the one I made first... Here is the script in the collectible

onClipEvent (enterFrame) {
if (this.hitTest(_root.char)) {
_root.score += 1;
unloadMovie(this)
}
}

The code in the character is just some code to let him move by the arrow keys... So can anyone help me? Please, I am new to actionscript (almost) I have been using basic commands for animations like "stop();" But I am pretty much new to making games and stuff... But I look forward to uploading games to this site... Please help.

sonic180
sonic180
  • Member since: Feb. 4, 2006
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to New to actionscript... 2008-12-11 11:12:31 Reply

Sorry for double post, but I just found out if I change every collectibles instance name then it lets me pick them up and gives me my score =D but is there a better way to do this then having to give each one a different instance name?

Treerung
Treerung
  • Member since: Apr. 18, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to New to actionscript... 2008-12-11 11:18:23 Reply

Try:

onClipEvent (enterFrame) {
if (this.hitTest(_root.char)) {
_root.score += 1;
this._visible=false;
}
}

:'(

BBS Signature
sonic180
sonic180
  • Member since: Feb. 4, 2006
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to New to actionscript... 2008-12-11 11:24:12 Reply

That only makes the MC go invisible and my score just keeps going up, I got to 100 score in about, three seconds.... Plus when I added more, it made the one I made first go invisible and it deleted the other ones =/...

ssjskipp
ssjskipp
  • Member since: Oct. 16, 2003
  • Offline.
Forum Stats
Member
Level 15
Programmer
Response to New to actionscript... 2008-12-11 12:52:57 Reply

then do the work around, set it's _x and _y to WAY off screen.


"Give a man a match, and he'll be warm for a minute, but set him on fire, and he'll be warm for the rest of his life."

UnknownFury
UnknownFury
  • Member since: Aug. 10, 2005
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to New to actionscript... 2008-12-11 13:10:05 Reply

At 12/11/08 12:52 PM, ssjskipp wrote: then do the work around, set it's _x and _y to WAY off screen.

No.

onClipEvent (enterFrame) {
if (this.hitTest(_root.char)) {
_root.score += 1;
this.swapDepths(_root.getNextHighestDepth());
this.removeMovieClip();
}
sonic180
sonic180
  • Member since: Feb. 4, 2006
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to New to actionscript... 2008-12-11 15:38:28 Reply

Hmm, that did not work either =(... It did do this weird thing where, I could not collect the copy until I collected the first one... And I had to collect the first one two times which gave me a score of 3 after collecting all of them...

ssjskipp
ssjskipp
  • Member since: Oct. 16, 2003
  • Offline.
Forum Stats
Member
Level 15
Programmer
Response to New to actionscript... 2008-12-11 20:53:24 Reply

At 12/11/08 01:10 PM, UnknownFury wrote:
At 12/11/08 12:52 PM, ssjskipp wrote: then do the work around, set it's _x and _y to WAY off screen.
No.

onClipEvent (enterFrame) {
if (this.hitTest(_root.char)) {
_root.score += 1;
this.swapDepths(_root.getNextHighestDept h());
this.removeMovieClip();
}

Close, but my guess is _root isn't going to cut it. Try:

onClipEvent (enterFrame) {
if (this.hitTest(_root.char)) {
_root.score += 1;
this.swapDepths(_parent.getNextHighestDepth());
_parent.removeMovieClip(this);
}

"Give a man a match, and he'll be warm for a minute, but set him on fire, and he'll be warm for the rest of his life."

CrustySheet
CrustySheet
  • Member since: May. 3, 2006
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to New to actionscript... 2008-12-11 21:03:35 Reply

you will need to use an an array with attach movie or duplicate :)