| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1681 人关注过本帖
标题:小妹初来乍到,向各路高手请教!
只看楼主 加入收藏
我不会做题
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2020-8-20
收藏
 问题点数:0 回复次数:4 
小妹初来乍到,向各路高手请教!
谢谢各位大神
   
图片附件: 游客没有浏览图片的权限,请 登录注册
题干
    参考目标效果完成制作
    添加帧频函数: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
    }
}

}
















搜索更多相关主题的帖子: app new set event var 
2020-08-20 13:57
HZYCR
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2017-2-7
收藏
得分:0 
你可以尝试发在js板块问一下
2020-10-22 15:56
rh2020
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2020-10-27
收藏
得分:0 
我才是新手,我完全看不明白
2020-10-27 22:02
Hacker_Lin
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2020-8-24
收藏
得分:0 
为什么我在java板块看见js代码
2020-11-02 17:35
快速回复:小妹初来乍到,向各路高手请教!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015970 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved