拖放问题
Phaser.js Drag and drop Problems
我正尝试着创造一款匹配游戏,即你拥有4个精灵,其中3个精灵都带有某些内容,而另一个精灵则拥有类似于答案的内容,例如,问题可能是分数和小数的匹配,而你将拥有3个分数或3个小数,而你将与之匹配的另一个精灵的对立面之一作为正确答案。但我的问题是,我不能让精灵欺骗他们碰撞。以下是我目前所掌握的信息。
/*
* 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");
}
}
在create函数中启用s1 game.physics.arcade.enable(s1);
的物理game.physics.arcade.overlap(cone,s1,collisionHandler,null,this);
在update函数请求时执行。你也可以使用game.physics.arcade。碰撞(//你params);
这里有一些链接可能会有帮助-检测碰撞和重叠
与缩放精灵重叠
相关文章:
- 拖放区 AMD 需要 JS 问题
- jQuery 性能问题,通过为新元素启用拖放
- 拖放保存定位问题
- Jquery UI表拖放问题
- jQueryUI-拖放问题-拖动的元素位于其他DOM元素之后
- HTML5拖放;Internet Explorer中的删除问题(无法访问dataTransfer属性)
- 角度拖放保存在数据库中的位置和屏幕大小调整问题
- Jquery拖放问题
- 我的拖放插件有问题
- webkitGetAsEntry的Javascript拖放文件上传问题
- jQuery UI拖放鼠标位置问题
- 拖放问题jquery
- Html5拖放显示id的问题
- SVG嵌入到HTML中,拖放代码问题
- 拖放问题
- 剑道网格拖放问题
- 拖放问题firefox
- Jquery -我有拖放的问题
- jQuery可排序的拖放-克隆和其他问题
- JavaScript拖放类/ID问题