[FONT=Times New Roman][SIZE=3]Hello, I am having trouble with detecting collisions in a game I am making. A part of my game requires bubbles to be generated from a character and for them to interact with each other (like in bubble bobble for nes). Currently I am trying to do this by having one bubble that is duplicated and given a new name of bubble# with # being a number that is generated by a counter in the character’s movieclip. The problem with this is that I have no way of telling the newly spawned bubbles to interact with bubble1,2,3,4,5…. [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]I have included a scratch version of the bubbles with this post, and will give the actionscript applied to each movieclip for those of you who do not wish to download the file. [/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Also, I should note that I am using Actionscript 2.0[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Character (red square):[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]onClipEvent (load) {[/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]readytofire = true[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]_root.bubblenumber = 1[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]}[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]onClipEvent (enterFrame) {[/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]trace(n)[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]_root.bubblenumber += 1[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]n = _root.bubblenumber[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]if (Key.isDown(Key.UP)) {[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._y -= 10;[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]if (Key.isDown(Key.DOWN)) {[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._y += 10;[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]if (Key.isDown(Key.LEFT)) {[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._x -= 10;[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]if (Key.isDown(Key.RIGHT)) {[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._x += 10;[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]if (Key.isDown(Key.SPACE) && readytofire) {[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]_root.bubble.duplicateMovieClip(“bubble”+n, n, {_x:this._x, _y:this._y});[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]countdowntimer = 10[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]readytofire = false[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]countdowntimer -= 1[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]if(countdowntimer < 1){[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]readytofire = true[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]}[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Original bubble (blue circle):[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]onClipEvent(load){[/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]b = _root.bubblenumber[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]h = Number < b [/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]}[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]onClipEvent(enterFrame){[/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman]this._y -= 5[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]if(_root.roof.hitTest(this._x,this._y,true)){[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._y += 5[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._x -= 2[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]if(_root.roof2.hitTest(this._x,this._y,true)){[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._y += 5[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._x += 2[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]if(_root.roof3.hitTest(this._x,this._y,true)){[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._y += 5[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._x -= 2[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]if(_root.roof4.hitTest(this._x,this._y,true)){[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._y += 5[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._x += 2[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]if(_root[“bubble”+h].hitTest(this._x,this._y,true)){ [/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._x = 100[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]this._y = 100[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]}[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]}[/SIZE][/FONT]