Description

A side-scrolling game or side-scroller is a video game in which the gameplay action is viewed from a side-view camera angle, and the onscreen characters generally move from the left side of the screen to the right

http://en.wikipedia.org/wiki/Side-scrollingvideogame

Usage

Constructor

  • scene {CanvasEngine.Scene}

  • tile_h {Integer}

    Height of the tile

  • tile_w {Integer}

    width of the tile

Example

var canvas = CE.defines("canvas_id").
    extend(Scrolling).
    ready(function() {
        canvas.Scene.call("MyScene");
    });

canvas.Scene.new({
    name: "MyScene",
    ready: function(stage) {
        this.scrolling = canvas.Scrolling.new(this, 32, 32);

        var player = this.createElement();
        this.scrolling.setMainElement(player);

        var map = this.createElement();
        this.scrolling.addScroll({
           element: map, 
           speed: 3,
           block: true,
           width: 120,
           height: 50
        });
    },
    render: function(stage) {
        this.scrolling.update();
        stage.refresh();
    }
});

Methods

setMainElement

Defined the main element that will set the scrolling

addScroll

Add a layer scroll as the main element

setScreen

Center the camera on the X and Y positions assigned

update

Update scrolling. A call loop

mouseScroll

Performs the scrolling with the mouse.

Discussion