龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > JAVA开发 >

Java基于Swing实现的打猎射击游戏代码(4)

时间:2014-11-14 11:09来源:网络整理 作者:网络 点击:
分享到:
public void run() { parent = null; int width = 0; while (width = 0 || parent == null) {// 获取父容器宽度 if (parent == null) parent = getParent(); else width = parent.getWidth(); } // 从左向右

        public void run() {
                parent = null;
                int width = 0;
                while (width <= 0 || parent == null) {// 获取父容器宽度
                        if (parent == null)
                                parent = getParent();
                        else
                                width = parent.getWidth();
                }
                // 从左向右移动本组件
                for (int i = 0; i < width && parent != null; i += 8) {
                        setLocation(i, y);
                        try {
                                Thread.sleep(sleepTime);// 休眠片刻
                        } catch (InterruptedException e) {
                                e.printStackTrace();
                        }
                }
                if (parent != null) {
                        MainFrame.appScore(-score * 10); // 自然销毁将扣分
                }
                destory();
        }

精彩图集

赞助商链接