Package org.solarus.editor

Examples of org.solarus.editor.SpriteAnimation


        TreePath selectionPath = null;

        // Add a node for each animation.
        for (String animationName: sprite.getAnimationNames()) {
            SpriteAnimation animation = sprite.getAnimation(animationName);
            DefaultMutableTreeNode animationNode = createAnimationNode(animationName);
            root.add(animationNode);

            // Add a node for each direction of this animation.
            for (int i = 0; i < animation.getNbDirections(); i++) {
                DefaultMutableTreeNode directionNode = createDirectionNode(animationName, i);
                animationNode.add(directionNode);

                // Initially select the sprite's current animation and direction.
                if (animationName.equals(sprite.getSelectedAnimationName()) &&
View Full Code Here


     * @param animationName Name of an animation.
     * @return The node created.
     */
    private DefaultMutableTreeNode createAnimationNode(String animationName) {

        SpriteAnimation animation = sprite.getAnimation(animationName);
        animation.addObserver(this);
        DefaultMutableTreeNode animationNode = new DefaultMutableTreeNode(
                new NodeInfo(animation, animationName));
        animationNode.setAllowsChildren(true);

        return animationNode;
View Full Code Here

        DefaultMutableTreeNode root = getSpriteNode();
        for (int i = 0; i < root.getChildCount(); i++) {
            DefaultMutableTreeNode animationNode = (DefaultMutableTreeNode) root.getChildAt(i);
            NodeInfo info = (NodeInfo) animationNode.getUserObject();
            SpriteAnimation animation = (SpriteAnimation) info.getData();
            if (animation.getName().equals(animationName)) {
                return animationNode;
            }
        }

        throw new NoSuchElementException("No such animation: '" + animationName + "'");
View Full Code Here

     * @param directionIndex A direction.
     * @return The created node.
     */
    private DefaultMutableTreeNode createDirectionNode(String animationName, int directionIndex) {

        SpriteAnimation animation = sprite.getAnimation(animationName);
        SpriteAnimationDirection direction = animation.getDirection(directionIndex);
        direction.addObserver(this);
        DefaultMutableTreeNode directionNode = new DefaultMutableTreeNode(new NodeInfo(
                direction, getDirectionNodeText(animationName, directionIndex)
        ));
        directionNode.setAllowsChildren(false);
View Full Code Here

     * @param direction A direction in this animation.
     * @return The appropriate text.
     */
    private String getDirectionNodeText(String animationName, int direction) {

        SpriteAnimation animation = sprite.getAnimation(animationName);
        return "Direction " + animation.getDirectionName(direction);
    }
View Full Code Here

                        root,
                        root.getChildCount()
                );

                // Maybe the new animation already has directions.
                SpriteAnimation animation = sprite.getAnimation(animationName);
                for (int i = 0; i < animation.getNbDirections(); i++) {
                    DefaultMutableTreeNode directionNode = createDirectionNode(
                            animationName,
                            i
                            );
                    getTreeModel().insertNodeInto(
View Full Code Here

                sprite.unselectAnimation();
            }

            else if (data instanceof SpriteAnimation) {
                // A sprite animation: show it and show no direction.
                SpriteAnimation animation = (SpriteAnimation) data;
                sprite.unselectDirection();
                sprite.setSelectedAnimation(animation.getName());
            }

            else if (data instanceof SpriteAnimationDirection) {
                // A direction: show it and show its parent animation.
                SpriteAnimationDirection direction = (SpriteAnimationDirection) data;
View Full Code Here

     * @param animationNode An animation node.
     */
    private void updateDirectionTexts(DefaultMutableTreeNode animationNode) {

        NodeInfo animationNodeInfo = (NodeInfo) animationNode.getUserObject();
        SpriteAnimation animation = (SpriteAnimation) animationNodeInfo.getData();

        for (int i = 0; i < animation.getNbDirections(); i++) {
            DefaultMutableTreeNode directionNode = (DefaultMutableTreeNode) animationNode.getChildAt(i);
            NodeInfo nodeInfo = (NodeInfo) directionNode.getUserObject();
            nodeInfo.setText(getDirectionNodeText(animation.getName(), i));
            getTreeModel().nodeChanged(directionNode);
        }
    }
View Full Code Here

            if (sprite == null) {
                return;
            }

            SpriteAnimation animation = sprite.getSelectedAnimation();
            if (animation == null) {
                // No animation is selected.
                return;
            }
View Full Code Here

TOP

Related Classes of org.solarus.editor.SpriteAnimation

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.