Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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');
- game.state.add("level1",level1);
- game.state.add("level2",level2);
- }
- 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);
- game.physics.arcade.enable(s1);
- 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(){
- game.physics.arcade.overlap(cone,s1,collisionHandler,null,this);
- var style = {font: "32px comic sans", fill :"#000000", wordwrap: true, wordWrapWidth: cone.width,align:"center"};
- text.x = Math.floor(cone.x + cone.width / 2);
- text.y = Math.floor(cone.y + cone.height / 2);
- CX = cone.x;
- S1 = s1.x;
- // CY = s2.y;
- // console.log(CY);
- // console.log(CX);
- function collisionHandler(){
- console.log("game Over");
- game.state.load("level2");
- }
- //console.log(CX);
- //if(CX === S1){
- // console.log("Game Over");
- //T1 =game.add.text(145,210,"",style);
- //}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement