⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parallaxbackground.java

📁 一个java的免费游戏引擎,里面有文档,和例子
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 

package com.golden.gamedev.object.background;

import com.golden.gamedev.object.Background;
import java.awt.Graphics2D;
import java.awt.Rectangle;

public class ParallaxBackground extends Background
{

    private Background a[];
    private int b;

    public ParallaxBackground(Background abackground[])
    {
        a = abackground;
        b = abackground.length;
        b();
    }

    private void b()
    {
        for(int i = 0; i < b; i++)
        {
            if(a[i].getWidth() > getWidth())
                setSize(a[i].getWidth(), getHeight());
            if(a[i].getHeight() > getHeight())
                setSize(getWidth(), a[i].getHeight());
        }

    }

    public void setLocation(double d, double d1)
    {
        super.setLocation(d, d1);
        for(int i = 0; i < b; i++)
            a[i].setLocation((getX() * (double)(a[i].getWidth() - getClip().width)) / (double)(getWidth() - getClip().width), (getY() * (double)(a[i].getHeight() - getClip().height)) / (double)(getHeight() - getClip().height));

    }

    public void update(long l)
    {
        for(int i = 0; i < b; i++)
            a[i].update(l);

    }

    public void render(Graphics2D graphics2d)
    {
        for(int i = 0; i < b; i++)
            a[i].render(graphics2d);

    }

    public Background[] getParallaxBackground()
    {
        return a;
    }

    public void setParallaxBackground(Background abackground[])
    {
        a = abackground;
        b = abackground.length;
        b();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -