码迷,mamicode.com
首页 > 数据库 > 详细

RuPengGame 游戏引擎 基本表单使用 setGameSize setGameTitle alert loadBgView playSound pause closeSound confirm input createText setTextPosition setTextColor setTextFontSize hideText showText

时间:2017-10-14 18:29:44      阅读:355      评论:0      收藏:0      [点我收藏+]

标签:关闭   oid   控制   bool   ttext   main   第一个字符   public   bsp   

package com.swift;

import java.awt.Color;

import com.rupeng.game.GameCore;//导入游戏引擎包

//实现Runnable接口
public class GameCoreDemo implements Runnable {

    public static void main(String[] args) {
        GameCore.start(new GameCoreDemo());// 生成游戏对象,并让引擎启动它
    }

    // 覆写接口中的run()方法,控制游戏
    @Override
    public void run() {
        // 设置游戏界面的窗口大小和界面
        GameCore.setGameSize(1024, 768);// 设置游戏窗口大小
        GameCore.setGameTitle("聆听——心灵的感动");// 设置游戏窗口标题
        // 播放关闭一首歌曲,并设置播放时间和背景图片
        GameCore.alert("请听第一首歌曲,《凉凉》");
        GameCore.loadBgView("sansheng.jpg");
        GameCore.playSound("杨宗纬$凉凉.mp3", true);
        GameCore.loadBgView("feidong.gif");
        GameCore.pause(15000);// 设置停留10秒
        GameCore.closeSound("杨宗纬$凉凉.mp3");
        // 带确认、取消按钮的对话框
        boolean b = GameCore.confirm("你觉得好听吗?");
        if (b)
            GameCore.alert("你的回答是好听");
        else
            GameCore.alert("你的回答是不好听.");
        // 使用输入框,输入两个数求和
        String n1 = GameCore.input("", "请输入一个数");// 第一个字符串是文本框中默认的值
        String n2 = GameCore.input("", "请再输入一个数字");// 第一个字符串是文本框中默认的值
        GameCore.alert("两个数字的和是:" + (Integer.parseInt(n1) + Integer.parseInt(n2)));
        // 创建文本标签,并修改文本标签位置和颜色
        GameCore.createText(0, "Advancing Swift");
        GameCore.createText(1, "Never Waste your time anymore");
        GameCore.setTextPosition(0, 100, 100);
        GameCore.setTextPosition(1, 100, 200);
        GameCore.setTextColor(0, Color.BLUE);
        GameCore.setTextColor(1, new Color(255, 3, 3));
        GameCore.setTextFontSize(0, 30);
        GameCore.setTextFontSize(1, 18);
        //隐藏与显示文本标签
        if (GameCore.confirm("你想要隐藏文本标签?")) {
            GameCore.hideText(0);
            GameCore.hideText(1);
        }else {
            System.exit(0);
        }
        if (GameCore.confirm("你想要显示文本标签?")) {
            GameCore.showText(0);
            GameCore.showText(1);
            GameCore.pause(2000);
        }else {
            System.exit(0);
        }

    }
}

 

RuPengGame 游戏引擎 基本表单使用 setGameSize setGameTitle alert loadBgView playSound pause closeSound confirm input createText setTextPosition setTextColor setTextFontSize hideText showText

标签:关闭   oid   控制   bool   ttext   main   第一个字符   public   bsp   

原文地址:http://www.cnblogs.com/qingyundian/p/7667865.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!