Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Trouble with collision detection


Recommended Posts

I am having some problems with being able to have the "cone" sprite overlappingĀ  "S1" and not recongizing that they are overlapping, and I am also wondering if with the ay I am doing this it would be easy to have it switch levels when it is done and have like a start screen. Thanks for the help in advance.

* 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(){
var cone;
var text;
function create(){

back = game.add.sprite(0,0,'back');
s1 = game.add.sprite(500,250,'Shoot');
s2 = game.add.sprite(280,250,'Shoot');
s3 = game.add.sprite(60,250,'Shoot');
cone = game.add.sprite(300,400,'Cone');
cone.inputEnabled = true;

var style = {font: "32px comic sans", fill :"#ff0044", wordwrap: true, wordWrapWidth: cone.width,align:"center"};
text = game.add.text(0,0,"test",style);

function update(){
text.x = Math.floor(cone.x + cone.width / 2);
text.y = Math.floor(cone.y + cone.height / 2);
//CX = s2.x;
// CY = s2.y;
// console.log(CY);
// console.log(CX);
function collisionHandler(){
console.log("game Over");


Link to comment
Share on other sites


  • Recently Browsing   0 members

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