GameScroll

GameScroll is a library|system to make game with scroll in a easy way. It adds a lot of functionality and functions specially to make easier the developing of games and other stuff.

Links

Documentation

The Base

Using GameScroll, you create a scroll (or various), then you and “views” (Regions) to display it on the screen. ONE scroll, multiple views. Think in a Regions as a windows through you see a piece of the map.

GameScroll work with two regions, one knows as “Display Region”(DR), the other as “Move Region”(MR) and a “camera”. MR is inside DR. You can move the camera inside the move region without moving the scroll, when the camera is out of the move region, the scroll move to fit it inside, else if you have reached a map border.

You could also put various Regions working on the same “scroll”, for example for a 2Players-game. See an example of a screen:

gamescroll.jpg

Example of Use

/**
 * @author el conejo freak  -  www.theNinjaBunny.com
 */
class TestScroll {
 
	public static var sRegion:ScrollRegion;
 
	public static function main() {
 
 
 
		// Create a tiled map (2 dim)
		var mapAr = new Array(["mapa","mapa","mapa"],["mapa","mapa","mapa"],["mapa","mapa","mapa"]);
//		var mapAr = new Array("mapa","mapa");
		var map:TiledMap = new TiledMap(mapAr,1186,370);
 
		// Create a GameScroll
		var gs:GameScroll = new GameScroll(1,map);
 
 
		//Upper Region
		var testMC:MovieClip = _root.createEmptyMovieClip("testHolder",1337);
		var displayRegion:Region = new Region(0,0,550,200);
		var moveRegion:Region = new Region(100,50,350,100);
		sRegion = new ScrollRegion(testMC,displayRegion,moveRegion,1);
 
		//Lower Region
		var testMC2:MovieClip = _root.createEmptyMovieClip("testHolder2",1339);
		var displayRegion2:Region = new Region(0,200,550,200);
		var moveRegion2:Region = new Region(100,250,350,300);
		var sRegion2:ScrollRegion = new ScrollRegion(testMC2,displayRegion2,moveRegion2,1);
 
 
		// Create two obj
		var conejo:ScrollObject = new ScrollObject("conejo");
		conejo.x = conejo.y = 200;
		conejo.setScroll(1);
		// One is camera of sRegion
		sRegion.setCamera(conejo);
 
		var conejo2:ScrollObject = new ScrollObject("conejo");
		conejo2.x = conejo2.y = 300;
		conejo2.setScroll(1);
		// Other is camera of sRegion2
		sRegion2.setCamera(conejo2);
 
		// C00l effect
		sRegion2.setAlpha(25);
 
 
		// Move both objects, one automatic, other with the mouse
		var controler:MovieClip = _root.createEmptyMovieClip("control",1338);
		controler.sRegion2 = sRegion2;
		controler.onEnterFrame = function() {
			conejo.x = _root._xmouse-TestScroll.sRegion.xscroll;
			conejo.y = _root._ymouse-TestScroll.sRegion.yscroll;
			conejo2.x+=5;
			if(conejo2.x>700) {
				conejo2.x=50;
			};
		};
 
 
 
	}
 
}

FeedBack

If you know some bug, please send it to nodani@gmail.com

Discussion

Enter your comment
 
 
gamescroll.txt · Last modified: 2007/09/17 00:15 (external edit)
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki