SampleProject

From ScapeFX Wiki

Jump to: navigation, search

Contents

Introduction

This is a sample java project for an implementation of a ScapeFX client. It includes a build.xml file that can be run with Ant.

Eclipse Java IDE

We recommend using Eclipse to code your client and build the project. Download Eclipse and install it.

Download the SampleSFX project

Download the sample project as a zip file and unzip it into your Eclipse workspace. In Eclipse select File->New->Other.. Open the Java folder and select "Java Project from Existing Ant Buildfile" then click the Next button. Click the "Browse..." button and select the build.xml file in the sample project then click "Finish".

If you are interested in testing the client for your own game prior to buying you can apply to get the SampleSFX project for trial. To get the project please fill out this form: http://www.scapefx.com/samplesfx.php

Project structure

The project has the following structure:

/SampleSFX
  /src
     /samplesfx
        /persistent
        /plugins
           SampleHost.java
           SampleManager.java
           SamplePack.java
           SampleSkin.java
           SpecialCommands.java
  /build
  /deploy
        startup.jnlp
  /images
     /skin
        The contents of the skin folder
        is described in detail here: Skin
  /lib
     scapefx.jar
     scapefx_api.jar
     bsh-2.0b4.jar
     miglayout15-swing.jar
     swingx.jar
     swingx-ws-2009_04_19.jar
     swing-worker.jar
     xstream-1.2.jar
     xpp3-1.1.4.jar
  /signing
     gen-keystore.bat
     SampleKeystore
  build.xml

Add your plugins

The sample project includes some example plugins. If you wish to create your own plugins you simply add their classes in the plugins package and then add them to the arraylist with plugins in the SamplePack class.

You will have to change the code in some of these sample plugins in order for the client to work. For example the SampleHost.java plugin must be configured to connect to your site.

SampleHost.java
  Host data for the sample client. 
SampleManager.java
  This is an example of the ScapeFXPlugin_Bootup plugin that is loaded when the client is started.
SamplePack.java
  A ScapeFXPlugin_Pack that bundles together a set of plugins and makes it easier to deploy the client.
SampleSkin.java
  A ScapeFXPlugin_Skin plugin that sets the skin of the client. This plugin changes the appearance of the client
  together with the /images/skin/sampleskin folder and the images it contains.
SpecialCommands.java
  An example of a ScapeFXPlugin_CommandParser that searches for commands typed at the commandline. This particular example
  will look for a "help" command and open a web browser to search Wikipedia for the query.

Create a unique skin

The Skin page gives some information about how to change the appearance of the client by modifying the skin images that are used for all the components in the client UI. Simply replace the images for your own.

In the constructor of the SampleSkin class you can also set some colors and fonts for different components. These are available as methods in the ScapeFXPlugin_Skin abstract class.

Create a keystore

Modify the /signing/gen-keystore.bat file (or copy it and paste into a command prompt) to suit your organization. Preferrably you should instead use a site like GlobalSign or VeriSign to buy your own code signing certificate. The created SampleKeystore file is used in the build.xml script to sign the .jar files that you create. When you run the client through Java Web Start the jar files must be signed or it will throw exceptions.

Build the project

Build the project by right-clicking on the build.xml file, select Run as...->Ant Build

If everything is okay you should see "BUILD SUCCESSFUL" at the end of the console when the build is finished. If you run into problems please visit the support forum for more information about how to build with Ecliplse. Support Forums

Configure the startup file

Open the /deploy/startup.jnlp file in a text editor and change the information in it to suit your game. You may wish to change tags like "title" and "description".

Deploy your client

Create the dir on your website for the client and upload all the files from your /build/lib dir into the following structure:

your.site.com/samplesfx/
   /lib
      All files in your project build/lib dir (a bunch of jar files)
   startup.jnlp    (from your project /deploy folder)
   index.html      (from your project /deploy folder)

Now you can surf to your.site.com/samplesfx/index.html and click the "Click to Play!" link to start the client.

Run the client from Eclipse

It is possible to run the client directly from inside Eclipse without having to build after each change you do in your code. You can also use the Eclipse debugging and place breakpoints inside your code and step through each line real-time as you test your client.

For more information about how to set up Eclipse to run the sample project visit this page: Run SampleSFX In Eclipse