PDA

View Full Version : Multiple object map scrolling



Jpao
May 29th, 2004, 02:54 PM
Im kind of new to the whole game programming in actionscript and my code is very basic, nub style.
The example of the mario style game I have currently is located here: http://www.rheniummusic.com/chris/rheniumrpg2.html
As you can see i like to display exactly whats happening with my variables at all times.
Anyways, you can see my problem right away, the map will scroll, but only that one, the original block, scrolls with the map, the other instance of 'block' does not.

This is the code relative to the map scrolling:

function movemapleft(){
_root.perffunc = true;
_root.block._x -= _root.movespeed;
_root.ground._x -= _root.movespeed;

}
function movemapright(){
_root.perffunc = true;
_root.block._x += _root.movespeed;
_root.ground._x += _root.movespeed;
}

(BTW all of my code is located in the "God" movieclip, thats why that is there)
Now, i realize that by saying " _root.block._x -= _root.movespeed;", the _root makes it only the one object.
How can i make it so that it will scroll every instance of the object called block, no matter how many times i copy and paste it?

and if you need the rest of the code just let me know, ill post it.

Jpao
May 30th, 2004, 07:24 PM
Anybody have any idea?

Marz
May 31st, 2004, 01:15 AM
Well.... If you are looking to scroll every instance of block.. You will have to give each object of block a unique instance name in the first place....

block0, block1, block2... those are typically acceptable instance names....

Then.. Just use a for loop... to make sure all of them move when you move the map or scroll the map... Other factors will come into arise like whether the block is offscreen or not... But those can be covered at another time.