# New Game

**URL:** <https://forum.kirupa.com/t/new-game/312017>\
**Category:** Uncategorized\
**Created:** [July 22, 2010, 2:44pm UTC](https://forum.kirupa.com/t/new-game/312017 "2010-07-22T14:44:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drumlegend](https://avatars.discourse-cdn.com/v4/letter/d/6bbea6/32.png) [@Drumlegend](https://forum.kirupa.com/u/Drumlegend)\
**Post date:** [July 22, 2010, 2:44pm UTC](https://forum.kirupa.com/t/new-game/312017/1 "2010-07-22T14:44:22Z")

</div>

//stop on current frame  
stop();  
//ball follows mouse  
ball1.addEventListener(MouseEvent.CLICK, clickEnter);  
function clickEnter(eventObj:MouseEvent):void {  
gotoAndPlay(1,“Menu”);  
}

this.addEventListener(Event.ENTER\_FRAME,follow);  
function follow(evt:Event){  
var xMouse:Number = root.stage.mouseX;  
var yMouse:Number = root.stage.mouseY;  
var xH:Number = ball1.x  
var yH:Number = ball1.y  
if(Math.abs(xMouse - xH)\<1){  
ball1.x = xMouse;  
ball1.y = yMouse;  
} else {  
ball1.x -= (ball1.x-xMouse) / 5;  
ball1.y -= (ball1.y-yMouse) / 5;}  
}  
//pixels spawn around outside the screen  
//make new array  
var particles=new Array();  
// add a listener that activates every frame  
addEventListener(Event.ENTER\_FRAME, loop);  
//explain the loop function  
function loop(e:Event) {  
//make new enemy  
var p = new Pixel();   
//add a new pixel onto the list  
particles.push§;  
//position the new pixel around the screen  
//position the new pixel outside the screen  
p.x=220;  
p.y=400;  
//pixel speed properties  
p.xspeed=-5+Math.random()\*10;  
p.yspeed=Math.random()\*10;  
//add object  
addChild§;

```
for (var count=0; count&lt;particles.length; count=count+1) {
	// update the current object based on its own speed
	particles[count].x=particles[count].x+particles[count].xspeed;
	// the square brackets are used to tell the array which object we want.
	

	
	
	
	
	
	
	// if the count variable is current set to 1, we're saying we want to access the object stored at particles[1]
	particles[count].y=particles[count].y-particles[count].yspeed;
	// reduce the objects yspeed to simulate gravity
	particles[count].yspeed=particles[count].yspeed-0.1;
	
	// we need to delete the particle if it has gone off the screen
	// check if the particle is off screen
	if (particles[count].y&gt;410) {
		//remove this particle from the screen
		removeChild(particles[count]);
		// delete this object from the list
		particles.splice(count, 1); // splie means delete. count indicates where to start deleting and the 1 means we only want to delete 1 thing
		// finally, to avoid any errors, we reduce our count by 1 to match the object we just deleted
		count=count-1;
	}
} // this ends the for loop

```

}

So far this is my action script…  
What I am trying to achieve is to make my ball get larger each time it collects a particle (Pixel). I am still new to as3 and would really appreciate the help with it.  
I understand I need to apply a hit test but from there I dont really know. Thanks in advance:)
