“远古帝国2”的片头图片抖动代码

FW; http://blog.sina.com.cn/u/56d4ddfb010005q3

这个是手机游戏“远古帝国2”的片头图片抖动代码~~写的相当不错~~我给大家贴一下~~在这里感谢一下南京朋友~~

    public static final void drawEffect(Graphics g, int current, int sum, int type, Image img, int x, int y, int t)
    {
        int width;
        int height;
        if(type == 0)
        {
            width = img.getWidth();
            height = img.getHeight();
        } else
        {
            height = img.getHeight();
            width = img.getWidth();
        }
        int halfWidth = width / 2;
        int wholeHeight = height / 1;
        int currentWidth = (width * current) / sum;
        int l3 = (width * (sum - current)) / (sum * 4);//每改变一个记数点x的改变量,举例,在LOGO的变化中为 width*current
        int currentAngle = (360 * current) / sum;
        int angle = (360 * t) / wholeHeight;//每增加一行的像素,角度增加量,t 决定了有几个弧形循环
        for(int i = 0; i < wholeHeight; i++)
        {
            int moveX = l3 * cos(currentAngle) >> 10;
            if(type == 0)
            {
                g.setClip(((x + halfWidth) - currentWidth / 2) + moveX, y + i * 1, currentWidth, 1);
                g.drawImage(img,x+moveX, y ,20);
            } else
            {
                g.setClip(x + i * 1, ((y + halfWidth) - currentWidth / 2) + moveX, 1, currentWidth);
                g.drawImage(img,x, y + movex,20);
            }
            currentAngle += angle;
        }

    }

更改里面的函数中的current变量就可以了~~

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值