2

私はBlackberryJava開発者です。シンプルなスロットマシンのロジックを開発しようとしています。ブラックベリーのアニメーショングラフィックスなどは初めてです。だから、ボタンを押すと3ブロックの画像が回転し始め、停止した後、写真に従って賞品が表示されるシンプルなスロットマシンを設計する方法を誰かに教えてもらえますか?それで、uplzはそれを行う方法のいくつかのサンプルまたはチュートリアルで私を助けることができます...

編集:私はそれをお金の取引を伴わない楽しいアプリケーションと同じように開発しています。したがって、Blackberry開発者のplzは、タスクを実行し、ボタンをクリックするだけで3つの画像を回転させる方法を教えてくれます...

4

2 に答える 2

3

これは簡単な例ですが、装飾やスムーズなローリングなどを自分で行う必要があります。

70x70の画像が6枚あるとします。現在のスロット画像、上の画像の半分と下の画像の半分をペイントするための単純なBitmapField拡張:

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);
    }
}

代替テキストhttp://img534.imageshack.us/img534/2172/slots.jpg

UI機能については以下をお読みください

Blackberryユーザーインターフェイスデザイン-カスタマイズ可能なUI?

ブラックベリー-フィールドレイアウトアニメーション

于 2010-07-12T17:28:28.207 に答える
0

ゲーム機でのメカニカルリールのシミュレーションは、米国特許7452276によって保護されています。特許のWebページには、ソフトウェアの開発を開始する前に調査する必要のある他の40の米国および国際特許へのリンクがあります。

さまざまな米国および国際的な特許権者のすべてからソフトウェアの開発許可を受け取った後、さまざまな画像を含む長い.gifストリップを作成し、3つ以上の位置にすばやく移動します。ソフトウェアは、.gifストリップの表示部分の上端と下端を歪ませて、機械的なスロットホイールの外観を与える必要があります。

于 2010-07-07T13:30:19.560 に答える