小妹初来乍到,向各路高手请教!
谢谢各位大神题干
参考目标效果完成制作
添加帧频函数:animate
设置 bullet 向上移动(30 像素/帧)
设置 bulletLeft 向上移动(30 像素/帧)
设置 bulletRight 向上移动(30 像素/帧);
当bullet.y<-50时
设置bullet y:plane.y-50、bullet x: plane.x、
设置bulletLeft y:plane.y、bulletLeft x:plane.x-100、
设置bulletRight y:plane.y、 bulletRight x:plane.x+100;
小妹不知问题在哪里
var app = new PIXI.Application(500,600);
document.body.appendChild(app.view);
var bg = new PIXI.Sprite.fromImage("res/plane/bg/img_bg_level_3.jpg");
app.stage.addChild(bg);
var bullet = new PIXI.Sprite.fromImage("res/plane/bullet/img_bullet_14.png");
bullet.anchor.set(0.5,0.5);
app.stage.addChild(bullet);
var bulletLeft = new PIXI.Sprite.fromImage("res/plane/bullet/img_bullet_13.png");
bulletLeft.anchor.set(0.5,0.5);
app.stage.addChild(bulletLeft);
var bulletRight = new PIXI.Sprite.fromImage("res/plane/bullet/img_bullet_13.png");
bulletRight.anchor.set(0.5,0.5);
app.stage.addChild(bulletRight);
var plane = new PIXI.Sprite.fromImage("res/plane_blue_01.png");
plane.anchor.set(0.5,0.5);
plane.x = 250;
plane.y = 500;
app.stage.addChild(plane);
var planeLeft = new PIXI.Sprite.fromImage("res/plane/liaoji_02_11.png");
planeLeft.anchor.set(0.5,0.5);
planeLeft.x = -100;
planeLeft.y = 50;
plane.addChild(planeLeft);
var planeRight = new PIXI.Sprite.fromImage("res/plane/liaoji_02_11.png");
planeRight.anchor.set(0.5,0.5);
planeRight.x = 100;
planeRight.y = 50;
plane.addChild(planeRight);
bg.interactive = true;
bg.on("mousemove",movePlane);
function movePlane(event){
var pos = event.data.getLocalPosition(app.stage);
plane.x = pos.x;
plane.y = pos.y;
}
bullet.interactive = true;
bullet.on("mousemove",animate);
function animate(event){
var pos = event.data.getLocalPosition(app.stage);
bullet.anchor.set(0.5,0.5);
bullet.x = pos.x;
bullet.y = pos.y;
app.ticker.add(animate);
function animate(){
bullet.y -= 30;
if(bullet.y<-50){
bullet.y = plane.y-50
bullet.x = plane.x
}
}
}
bulletLeft.interactive = true;
bulletLeft.on("mousemove",animate1);
function animate1(event){
var pos = event.data.getLocalPosition(app.stage);
bulletLeft.anchor.set(0.5,0.5);
bulletLeft.x = pos.x;
bulletLeft.y = pos.y;
app.ticker.add(animate);
function animate(){
bulletLeft.y -= 30;
if(bulletLeft.y<-50){
bulletLeft.y = plane.y
bulletLeft.x = plane.x-100
}
}
}
bulletRight.interactive = true;
bulletRight.on("mousemove",animate2);
function animate2(event){
var pos = event.data.getLocalPosition(app.stage);
bulletRight.anchor.set(0.5,0.5);
bulletRight.x = pos.x;
bulletRight.y = pos.y;
app.ticker.add(animate);
function animate(){
bulletRight.y -= 30;
if(bulletRight.y<-50){
bulletRight.y = plane.y
bulletRight.x = plane.x+100
}
}
}