Need help with several problems(such as enemy clipping and loading movieclips into an array)

4 posts

Flag Post

I am very new to as3 and due to me being sick I am behind on schedule and I could really use some help. Basically I made a top down evasion game. Using this tutorial as a basis

I have several problems I have to solve:
1: I need a scrolling background.(I do this using to movieclips but they wont switch to another value for y)

2: I need to prevent my enemies from clipping (I use multiple sorts of enemies).

3: I need to load enemies into an array to spawn them in a pattern.

Probably the most easy one is that I need and endless scrolling background.
It basically are two versions of a movieclip scrolling down and when reaching a certain value for y they should move back up. It starts of good, meaning the 2 versions scroll down but they won’t move back up.

This is the code I am using:

//The speed of the scroll movement.
var scrollSpeed:uint = 6;

//This adds two instances of the movie clip onto the stage.
var s1:ScrollBg = new ScrollBg();
var s2:ScrollBg = new ScrollBg();

//This positions the second movieclip next to the first one.
s1.y = 0;
s2.y = s1.height;

//Adds an event listener to the stage.
stage.addEventListener(Event.ENTER_FRAME, moveScroll);

//This function moves both the images to left. If the first and second 
//images goes pass the left stage boundary then it gets moved to 
//the other side of the stage. 
function moveScroll(e:Event):void
	s1.y +=  scrollSpeed;
	s2.y +=  scrollSpeed;

	if (s1.y <  -  s1.height)
		s1.y = s2.height;
	else if (s2.y < -s1.height)
		s2.y = s2.height;

Any ideas?

For the enemies I use this code here

and here

I dont want the enemies to overlap each other so i thought i would make them hit test each other and removing one of them when the hit test is true but nothing happens.

Also I need to spawn a pattern of enemies Could you possibly help me on that?

Sorry for the wall of text, but I really need help and any help would be appreciated.

Thanks in advance.
Greetings Ryco.

Flag Post

Count 1 skyboy. :D I’ll edit the Proper Code Formatting in. Then I’ll see if I can help.

Wait wat. How does that possibly move them to the left if your scrollSpeed is positive and you add those to the y values. That should be moving them down.

For the scrolling background, the if statements probably should look like:

s1.y = 0;
s2.y = -s1.height; //negative so we can place it above it. (y values increase as you go down)

//your 2 if statements
if (s1.y > s1.height)
	s1.y = 0;
	s2.y = -s1.height;
Flag Post

Ahh great, I thought y values increased if you went down. Got it now thanks for the quick response.

Flag Post

Originally posted by UnknownGuardian:

Count 1 skyboy. :D I’ll edit the Proper Code Formatting in. Then I’ll see if I can help.

unsticking it isn’t going to help any; an HTML popup (that is: not using when people first load the page (saved as a cookie) would help stop the threads asking how to make a game and point them at how to format their posts

i pointed out that the problem is mostly from people who don’t have much experience on forums: new programmers, and particularly new flash programmers