Package com.threerings.media.sprite

Examples of com.threerings.media.sprite.Sprite


        // can't do anything if we don't know where the mouse pointer is
        if (_mouseEvent == null) {
            return;
        }

        Sprite newHighestHit = _spritemgr.getHighestHitSprite(
            _mouseEvent.getX(), _mouseEvent.getY());

        CardSprite newActiveCardSprite =
            (newHighestHit instanceof CardSprite ? (CardSprite)newHighestHit : null);
View Full Code Here


        if (!inBounds(tx, ty)) {
            log.warning("Requested to create and move piece to invalid location",
                "tx", tx, "ty", ty, new Exception());
            return;
        }
        Sprite sprite = createPieceSprite(piece, sx, sy);
        if (sprite != null) {
            // position the piece properly to start
            Point start = new Point();
            getPiecePosition(sx, sy, start);
            sprite.setLocation(start.x, start.y);
            // now add it to the view
            addSprite(sprite);
            // and potentially move it into place
            movePiece(sprite, sx, sy, tx, ty, duration);
        }
View Full Code Here

     * @return the piece sprite that is being moved.
     */
    public Sprite movePiece (int sx, int sy, int tx, int ty, long duration)
    {
        int spos = sy * _bwid + sx;
        Sprite piece = _pieces[spos];
        if (piece == null) {
            log.warning("Missing source sprite for drop", "sx", sx, "sy", sy, "tx", tx, "ty", ty);
            return null;
        }
        _pieces[spos] = null;
View Full Code Here

    public void setBoard (Board board)
    {
        // when a new board arrives, we want to remove all drop sprites
        // so that they don't modify the new board with their old ideas
        for (Iterator<Sprite> iter = _actionSprites.iterator(); iter.hasNext(); ) {
            Sprite s = iter.next();
            if (s instanceof DropSprite) {
                // remove it from _sprites safely
                iter.remove();
                // but then use the standard removal method
                removeSprite(s);
            }
        }

        // remove all of this board's piece sprites
        int pcount = (_pieces == null) ? 0 : _pieces.length;
        for (int ii = 0; ii < pcount; ii++) {
            if (_pieces[ii] != null) {
                removeSprite(_pieces[ii]);
            }
        }

        super.setBoard(board);

        _dboard = (DropBoard)board;

        // create the pieces for the new board
        Point spos = new Point();
        int width = _dboard.getWidth(), height = _dboard.getHeight();
        _pieces = new Sprite[width * height];
        for (int yy = 0; yy < height; yy++) {
            for (int xx = 0; xx < width; xx++) {
                Sprite piece = createPieceSprite(_dboard.getPiece(xx, yy), xx, yy);
                if (piece != null) {
                    int ppos = yy * width + xx;
                    getPiecePosition(xx, yy, spos);
                    piece.setLocation(spos.x, spos.y);
                    addSprite(piece);
                    _pieces[ppos] = piece;
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.threerings.media.sprite.Sprite

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.