BlackBerryでスロットマシンを設計します
-
02-10-2019 - |
質問
私はBlackBerry Java開発者です。シンプルなスロットマシンロジックを開発しようとしています。私はブラックベリーのアニメーショングラフィックなどに慣れていません。そのため、ボタンを押すと3ブロックの画像が回転を開始する必要があり、停止した後、写真に従って賞品が表示される必要があるシンプルなスロットマシンの設計方法を誰でも教えてもらえます。だから、あなたはそれを行う方法のいくつかのサンプルやチュートリアルを手伝ってくれますか...
編集:私はお金の取引を伴わない楽しいアプリケーションと同じように開発しています。したがって、BlackBerry Developers PLZは、タスクを達成し、ボタンをクリックすると3つの画像をスピンする方法を教えてください...
解決
これは簡単な例ですが、自分で装飾、滑らかな転がりなどに対処する必要があります。
6つの画像70x70があるとしましょう。現在のスロット画像をペイントするためのシンプルなビットマップフィールド拡張機能、上の画像の半分と下の画像の半分:
class SlotField extends BitmapField {
Bitmap bmp1 = Bitmap.getBitmapResource("img1.png");
Bitmap bmp2 = Bitmap.getBitmapResource("img2.png");
Bitmap bmp3 = Bitmap.getBitmapResource("img3.png");
Bitmap bmp4 = Bitmap.getBitmapResource("img4.png");
Bitmap bmp5 = Bitmap.getBitmapResource("img5.png");
Bitmap bmp6 = Bitmap.getBitmapResource("img6.png");
Bitmap[] bmps = new Bitmap[] { bmp1, bmp2, bmp3, bmp4, bmp5, bmp6 };
int mPos = 0;
public SlotField(int position) {
mPos = position;
}
public int getBitmapHeight() {
return bmp1.getHeight() * 2;
}
public int getBitmapWidth() {
return bmp1.getWidth();
}
protected void layout(int width, int height) {
setExtent(getBitmapWidth(), getBitmapHeight());
}
int getNextPos() {
if (mPos == bmps.length - 1) {
return 0;
} else
return mPos + 1;
}
int getPrevPos() {
if (mPos == 0) {
return bmps.length - 1;
} else
return mPos - 1;
}
protected void paint(Graphics g) {
Bitmap hImg = bmps[getPrevPos()];
Bitmap mImg = bmps[mPos];
Bitmap lImg = bmps[getNextPos()];
g.drawBitmap(0, 0, 70, 35, hImg, 0, 35);
g.drawBitmap(0, 35, 70, 70, mImg, 0, 0);
g.drawBitmap(0, 105, 70, 35, lImg, 0, 0);
}
}
これらのフィールドを画面に置き、タイマーでアニメーション化します。
class MainScr extends MainScreen {
SlotField slot1 = new SlotField(0);
SlotField slot2 = new SlotField(3);
SlotField slot3 = new SlotField(5);
boolean running = false;
public MainScr() {
HorizontalFieldManager hField = new HorizontalFieldManager();
add(hField);
hField.add(slot1);
hField.add(slot2);
hField.add(slot3);
ButtonField btnRoll = new ButtonField("Roll");
btnRoll.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
if (!running)
rollSlots();
}
});
add(btnRoll);
}
void rollSlots() {
Timer timer = new Timer();
final Random rnd = new Random();
TimerTask ttask1 = new TimerTask() {
int cycle = 0;
public void run() {
slot1.mPos = slot1.getNextPos();
invalidate();
cycle++;
if (cycle >= 100+rnd.nextInt(6))
cancel();
}
};
TimerTask ttask2 = new TimerTask() {
int cycle = 0;
public void run() {
slot2.mPos = slot2.getNextPos();
invalidate();
cycle++;
if (cycle >= 100+rnd.nextInt(6))
cancel();
}
};
TimerTask ttask3 = new TimerTask() {
int cycle = 0;
public void run() {
slot3.mPos = slot3.getNextPos();
invalidate();
cycle++;
if (cycle >= 100+rnd.nextInt(6))
cancel();
}
};
timer.schedule(ttask1, 0, 50);
timer.schedule(ttask2, 200, 50);
timer.schedule(ttask3, 400, 50);
}
}
Alt Text http://img534.imageshack.us/img534/2172/slots.jpg
UI機能の場合は読み取ります
BlackBerryユーザーインターフェイス設計 - カスタマイズ可能なUI?
と
他のヒント
ゲーム機での機械リールのシミュレーションは、 米国特許7452276. 。特許ウェブページには、ソフトウェアの開発を開始する前に調査する必要がある他の40の米国および国際特許へのリンクがあります。
ソフトウェアを開発するために、さまざまな米国および国際的な特許所有者のすべてから許可を受けた後、3つ以上のポジションですぐに下に移動するさまざまな画像を備えた長い.gifストリップを開発します。あなたのソフトウェアは、機械的スロットホイールの外観を与えるために、.gifストリップの可視部分の上部と下のエッジを歪む必要があります。