1
我试图做一个匹配游戏,你有4个精灵,其中3个有他们的东西,另一个精灵有像anwnser例如问题可能是分数和小数的匹配和你会有3个小数或3位小数,其中一个oposite作为正确的awnser在另一个sprite上,你匹配正确的一个。但我的问题是,我不能让精灵来诋毁他们正在碰撞。这是我到目前为止。Phaser.js拖放问题
/*
* 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('star','pics/star.png');
}
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;
cone.input.enableDrag();
game.physics.enable(cone, Phaser.Physics.ARCADE);
var style = {font: "32px comic sans", fill :"#ff0044", wordwrap: true, wordWrapWidth: cone.width,align:"center"};
text = game.add.text(0,0, "test", style);
text.anchor.set(0.5);
}
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 = s2.x;
//CY = s2.y;
// console.log(CY);
// console.log(CX);
function collisionHandler() {
console.log("game Over");
}
}
好的,谢谢还我怎么能够切换水平,因为有没有真正了解如何切换和添加水平的任何好TUTS。 – Sabre
您可以通过在Phaser中使用* state *来切换关卡首先添加game.state.add(“BossLevel”,bossLevel);然后开始状态game.state.start('BossLevel');您可以在Phaser主页的示例部分中找到更多关于此的信息。 –
这里的教程不是很好,对我来说有点难理解,游戏状态部分。 – Sabre