Hello Ultima2876
I’ve tried to implement as you said. But still I got the still screen. No scrolling is there. I am posting my code. Please check and let me know what I am doing wrong.
// background entity for backdrop
package entities
{
import net.flashpunk.Entity;
import net.flashpunk.Graphic;
import net.flashpunk.graphics.Backdrop;
import net.flashpunk.Mask;
/**
* ...
* @author Deepak Singh Kushwah
*/
public class Background extends Entity
{
private var backdrop:Backdrop;
public function Background(x:Number = 0, y:Number = 0)
{
backdrop = new Backdrop(GA.BACK_IMG, true, true);
graphic = backdrop;
super(x, y, graphic);
}
override public function update():void {
backdrop.scrollX = 0.5;
backdrop.scrollY = 2.0;
super.update();
}
}
}
and adding it to level1.
package worlds
{
import entities.Background;
import entities.Currentlevel;
import entities.Enemy;
import entities.Player;
import entities.PlayerLives;
import entities.Score;
import net.flashpunk.Entity;
import net.flashpunk.graphics.Backdrop;
import net.flashpunk.World;
import net.flashpunk.FP;
/**
* ...
* @author Deepak Singh Kushwah
*/
public class Level1 extends World
{
private var player:Player;
private var enemy:Array;
private var back:Background;
public function Level1()
{
super();
}
override public function begin():void {
back = new Background(0,0);
add(back);
player = new Player(FP.screen.width*0.5, 500);
add(player);
add(new Enemy(GA.Rand(10, 750), 0, GA.Rand(10, 150)));
//FP.screen.color = 0xC5DDF9;
add(new Score(10, 10));
add(new PlayerLives(150, 10));
add(new Currentlevel(290, 10));
}
override public function update():void {
if (classCount(Enemy) < 5 ) {
//add(new Enemy(GA.Rand(10, 750), 0, GA.Rand(10, 150)));
}
if (GA.SCORE >= 20) {
GA.SCORE = 0;
GA.PLAYER_LIVES = 3;
GA.CURRENT_LEVEL = 2;
FP.world = new Level2;
}
super.update();
}
}
}
I am not able to post complete project because this site system says I am new user. So please check this code here and let me know what’s wrong.
Thanks & Regards