Jump to content

Help: Assigning Colliders to objects


Caveman1217
 Share

Recommended Posts

I need help!!

So i have been staring at example codes and tutorial for the past 4 hours and i still cant seem to get this thing to work. I am new to coding, but I have to learn in to keep up in my current job. If anyone has any suggestions or any pointers on how to make colliders work with this script I could use all the help i can get.

var game = new Phaser.Game(728, 1280, Phaser.CANVAS, 'Bombs_Away', { preload: preload, create: create, update: update, render: render });

function preload() { 
    game.load.atlas('assets', 'assets/Images/assets.png', 'assets/Images/assets.json', Phaser.Loader.TEXTURE_ATLAS_JSON_HASH);
    game.load.image('background', 'assets/Images/Background.png');  


  
}

function create() {
    
    game.physics.startSystem(Phaser.Physics.ARCADE);


    
        bg = game.add.sprite(0, 0, 'background');
        bg.width = 728;
        bg.height = 1280;
    
        sprite3 = game.add.sprite (-35, -190, 'assets', 'healthframe.png');
        sprite3.width = 300;
        //sprite1.hight = 5;
    
    
        herobase = game.add.sprite (0, 450, 'assets', 'herobase.png');
        game.physics.enable(herobase, Phaser.Physics.ARCADE);
        
   
        bomb = this.game.add.sprite (50, 0, 'assets', 'bomb');
        game.physics.enable( bomb, Phaser.Physics.ARCADE);
        bomb.body.velocity.y= 50 + Math.random() * 600;
        bomb.animations.add('fall', [0,1 ], 15, true);
        bomb.animations.play('fall');
    
       

        
        game.add.text(20,30, 'SCORE:', { font: "40px Impact", fill: "#ffffff" }); 
    

    
    }                    


function update(){
    
}

//function colliderHandler(obj1, obj2){
    

//}


function render (){
    
    
}
 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...