区块链技术博客
www.b2bchain.cn

标题: 小妹初来乍到,向各路高手请教!

b2bchain.cn区块链技术社区提供第8537篇技术文章标题: 小妹初来乍到,向各路高手请教!
问题解答:

小妹初来乍到,向各路高手请教!

谢谢各位大神
    题干
    参考目标效果完成制作
    添加帧频函数: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
    }
}

}

附件: 游客没有浏览附件的权限,请 登录注册

标题: 小妹初来乍到,向各路高手请教! 由www.b2bchain.cn 提供
文章整理自网络,只为个人学习与分享使用
链接地址https://www.b2bchain.cn/?p=8537

赞(0) 打赏
部分文章转自网络,侵权联系删除b2bchain区块链学习技术社区 » 标题: 小妹初来乍到,向各路高手请教!
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

b2b链

联系我们联系我们