Hi, i'm trying use screenfade but it's not working for some reason.
server-side
Code:player.getPA().sendScreenFade("Welcome to Zulrah's shrine", 1, 5);
client-sideCode:public void sendScreenFade(String text, int state, int seconds) {
if (c == null || c.getOutStream() == null) {
return;
}
if (seconds < 1 && state != 0) {
throw new IllegalArgumentException("The amount of seconds cannot be less than one.");
}
c.getOutStream().createFrameVarSize(9);
c.getOutStream().writeString(text);
c.getOutStream().writeByte(state);
c.getOutStream().writeByte(seconds);
c.getOutStream().endFrameVarSize();
}
Code:case 9:
String text = inStream.readString();
byte state = inStream.readSignedByte();
byte seconds = inStream.readSignedByte();
fadingScreen = new FadingScreen(text, state, seconds);
incomingPacket = -1;
return true;
anyone idea? thanks in advance.Code:package com.client.graphics;
import org.apache.commons.lang3.time.StopWatch;
import com.client.DrawingArea;
import com.client.RSFont;
public class FadingScreen {
public RSFont newRegularFont;
//private FadingScreen fadingScreen = new FadingScreen();
/**
* The state of the fade on the screen
*/
public byte state;
/**
* How many seconds the fade exists for
*/
public byte seconds;
/**
* The string of text that will be displayed on the screen
*/
public String text;
/**
* Controls how long it's been since the screen started its last fade
*/
public StopWatch watch;
/**
* Acts as a means to instance the local {@link FadingScreen} object.
* Since the value of state by default is 0, nothing will be drawn on
* the screen.
*/
public FadingScreen() { }
/**
* Creates a new fading screen
* @param state the state of the fade
* @param seconds the duration of the fade
*/
public FadingScreen(String text, byte state, byte seconds) {
this.text = text;
this.state = state;
this.seconds = seconds;
this.watch = new StopWatch();
this.watch.start();
}
/**
* Draws the animation on the screen. If the state of the
* screen is currenly 0 the animation will not be drawn.
*/
public void draw() {
if(state == 0) {
return;
}
long end = watch.getStartTime() + (1000L * seconds);
long increment = ((end - watch.getStartTime()) / 100);
if (increment > 0) {
long percentile = watch.getTime() / increment;
int opacity = (int) ((percentile * (Byte.MAX_VALUE / 100)) * 2);
if (state < 0) {
opacity = 255 - opacity;
}
if (percentile > -1 && percentile <= 100) {
DrawingArea.setDrawingArea(334, 0, 512, 0);
DrawingArea.drawAlphaBox(0, 0, 512, 334, 0x000000, opacity);
if (percentile > 85 && state == 1 || percentile < 50 && state == -1) {
newRegularFont.drawCenteredString(text, 512 / 2, 334 / 2, 0xFFFFFF, 0);
} else if (percentile == 100) {
watch.stop();
state = 0;
}
}
}
}
}