Jump to content

How can you creaste multiple levels in Phaser.js I have looked at the examples and am really confused about how I make them and then how I call them. here is my code right now.

* To change this license header, choose License Headers in Project Properties.* To change this template file, choose Tools | Templates* and open the template in the editor.*/var game = new Phaser.Game(800,600,Phaser.AUTO,'',{preload: preload, create: create, update: update});function preload(){game.load.image('Cone','pics/ICE-Cream-cone_1.png');game.load.image('back','pics/BakerIceBackground_1.png');game.load.image('Shoot','pics/CreamShoot.png');game.load.image('Title','pics/Baker-Ice-title_1.png');}var cone;var text;function create(){back = game.add.sprite(0,0,'back');title = game.add.sprite(200,0,'Title');title.scale.setTo(1,1);s3 = game.add.sprite(500,250,'Shoot');s2 = game.add.sprite(280,250,'Shoot');s1 = game.add.sprite(60,250,'Shoot');cone = game.add.sprite(300,430,'Cone');cone.inputEnabled = true;cone.input.enableDrag();game.physics.enable(cone,Phaser.Physics.ARCADE);var style = {font: "32px comic sans", fill :"#000000", wordwrap: true, wordWrapWidth: cone.width,align:"center"};text = game.add.text(0,0,".25",style);text.anchor.set(0.5);T1=game.add.text(145,210,"1/4",style);T2=game.add.text(360,210,"1/2",style);T3=game.add.text(580,210,"1/3",style);}function update(){text.x = Math.floor(cone.x + cone.width / 2);text.y = Math.floor(cone.y + cone.height / 2);// game.physics.arcade.overlap(cone,s1,collisionHandler,null,this);CX = cone.x;S1 = s1.x;// CY = s2.y;// console.log(CY);// console.log(CX);//function collisionHandler(){// console.log("game Over");//}//console.log(CX);if(CX === S1){console.log("Game Over");}}
Edited by prolemur
code tags, im not indenting this tho
Link to comment
https://linustechtips.com/topic/433735-multiple-levels-in-phaser/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×