您的位置:首页 > 其它

是什么能够两小时写出《flppybird》游戏--绘制场景

2015-03-02 08:50 197 查看
我参考了/article/11477374.html

这篇博客的技巧来实现flppybird的绘制管道。

这是最终效果 一定要点击效果哦。



下面的代码是我们参考博客的升级版

LoadImage("imageBird", ":/blog/游戏博客/flppybird/image/bird.png");

channelSprite=//创建管道的精灵
{
type:"sprite";
Blend: "alpha";
Width: 20%;
Height: 80%;
X:100%;
Y:50%;
attachCamera:true;//设置附着镜头 如果没有设为true,今天移动他就不会动
Texture: "imageBird";//设置纹理
CenterY: 100%;//中心点坐标Y(50%表示图中心)
Y:0;
Texcoord:{112/1024,645/1024,55/1024,320/1024};//纹理坐标
};

channelUpSprite = (
{
type:"sprite";
Blend: "alpha";//设置为透明
Width: 20%;
Height: 80%;
X:0;//下半截管道的X坐标和上半截的相同
attachCamera:true;
Y:50%;//生成下半截管道的Y坐标 加一个随机数是上面管道和下面的管道的空隙
Texture: "imageBird";
Texcoord:{168/1024,645/1024,55/1024,320/1024}//纹理坐标
});

//生成100对管道
foreach(1...100,
{
//上半截高度和X轴时随机的
space = 30;
case((30- value*0.2)> 20,
{
space =(30- value*0.2)
},
(30- value*0.2)< 29,
{
space=20
});//不断减小管道间的空隙
tempX = (50*value+rand(-5,10))%;
tempY = rand(10,40)%;
create({X:tempX;Y:tempY+space+rand(-5,2)}::channelUpSprite);
create({X:tempX;Y:tempY}::channelSprite);
});

Camera=//设置镜头的状态
{
viewX:0;//镜头的X位置为0;
};

setCamera(Camera);//设置镜头 系统函数
Camera.viewX <:{50,(500*70),350000};//设置镜头移动从50 到500*70 事件为350000ms也就是350秒


大家如果不熟悉这个函数多多看看官方的api哦 http://www.wooyoogame.com/api/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: