0
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create});
function preload() {
// You can fill the preloader with as many assets as your game requires
// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.
// The second parameter is the URL of the image (relative)
}
function create() {
// This creates a simple sprite that is using our loaded image and
// displays it on-screen
// and assign it to a variable
var image = game.add.sprite(0, 0, 'einstein');
game.physics.enable(image, Phaser.Physics.ARCADE);
image.body.velocity.x=150;
//my attempt below
if(image.body.coordinate.x > 1){
var image = game.add.sprite(0, 0, 'einstein');
}
}
我目前正尝试将图像精灵重置为坐标0,0,当它离开屏幕时完全离开屏幕,所以基本上一旦它离开画布就会重置并重置几个小时尝试了很多东西任何提示将不胜感激。正如我一直试图主动获取坐标,以便它知道何时在第一个图像消失时加载图像。如何在到达框架结尾时将其位置重置回原点? javascript
感谢
如何做任何提示? – 2015-03-02 20:33:54
它似乎只检查一次,它总是输出越界 – 2015-03-02 21:15:04
雅它仍然只是越界并不会重置 – 2015-03-02 21:21:16