Ir para conteúdo
Fórum Script Brasil
  • 0

AboutScreen.java


xXxVSNxXx

Pergunta

Buenas! sou novo na área de programação, e me deparei com um problema de um script pronto, mas não sei nem por onde começar, então se alguém poder me ajudar, ficaria grato...

OBS.: Esse é o script original e está funcionando corretamente.

package com.ximad.pvn.screens;

import com.ximad.pvn.engine.*;
import com.ximad.pvn.game.Textures;
import java.util.Vector;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

// Referenced classes of package com.ximad.pvn.screens:
//            HomeScreen

public class AboutScreen extends UiScreen
{
    class CustomTextBox extends Field
    {

        public void onPaint(Graphics g)
        {
            g.setColor(fontColor);
            g.setFont(Font.getFont(0, 0, 16));
            g.clipRect(left, top, width, height);
            for(int i = 0; i < strings.size(); i++)
            {
                int y = (top + i * fontHeight) - scrollPosition;
                if(y <= top + height && y + fontHeight >= top)
                {
                    String s = (String)strings.elementAt(i);
                    g.drawString(s, left, y, 20);
                }
            }

        }

        public void onIdle()
        {
            if(inertion && begin > 10)
            {
                if(delta > 0)
                    scrollPosition -= speed * 2;
                else
                if(delta < 0)
                    scrollPosition += speed * 2;
                if(scrollPosition < 0)
                    scrollPosition = 0;
                else
                if(scrollPosition > getMaxPosition())
                    scrollPosition = getMaxPosition();
                speed--;
                if(speed == 0)
                    inertion = false;
                repaint(left, top, width, height);
            }
        }

        public void append(String text)
        {
            strings.addElement(text);
        }

        private int getMaxPosition()
        {
            return fontHeight * strings.size() - height / 2;
        }

        public boolean touchEvent(int touchEventType, int eventX, int eventY)
        {
            boolean out = false;
            if(eventX < left || eventX > left + width || eventY < top || eventY > top + height)
                out = true;
            switch(touchEventType)
            {
            default:
                break;

            case 2: // '02'
                if(out)
                    return false;
                SCROLL = true;
                lastEventY = eventY;
                begin = eventY;
                inertion = false;
                break;

            case 1: // '01'
                SCROLL = false;
                if(delta > 1 || delta < -1)
                {
                    inertion = true;
                    speed = 10;
                }
                begin = eventY - begin;
                if(begin < 0)
                    begin *= -1;
                break;

            case 3: // '03'
                if(!SCROLL)
                    return false;
                delta = eventY - lastEventY;
                scrollPosition -= delta;
                lastEventY = eventY;
                if(scrollPosition < 0)
                    scrollPosition = 0;
                else
                if(scrollPosition > getMaxPosition())
                    scrollPosition = getMaxPosition();
                repaint(left, top, width, height);
                break;
            }
            return !out;
        }

        private Vector strings;
        private int fontHeight;
        private int fontColor;
        private boolean SCROLL;
        private int lastEventY;
        private int scrollPosition;
        private int delta;
        private int speed;
        private int begin;

        private CustomTextBox(int width, int height, int textColor)
        {
            strings = new Vector();
            this.width = width;
            this.height = height;
            fontHeight = Font.getDefaultFont().getHeight();
            fontColor = textColor;
        }

    }


    public AboutScreen()
    {
        inertion = false;
        CustomButton btBack = new CustomButton(Textures.back, 0, 1) {

            protected void touchAction()
            {
                Application.setScreen(HomeScreen.getInstance());
            }

        }
;
        lbAbout = new CustomTextBox(490, 200, 0x56290f);
        append();
        append("    There's an old feud between Angry  and");
        append("Pork,   so old that no one remembers");
        append();
        append("                             what started it");
        append();
        append("    Regardless, the fighting rages on to this");
        append("day,  and  it's  brought  to  your  Symbian");
        append("device  by  Arkantoz Angry Birds  in  their");
        append("struggle  (because  they  are  cuter  than");
        append("Pork)   ");
        append("    Command  Angry   and  destroy  the");
        append("camps of ruthless Pork  killers to defend");
        append("Angry ' homeland.");
        append();
        append("    Game objective:");
        append();
        append(" - Complete each level by clearing it of all");
        append("Pork    with  minimal  number  of  shots!");
        append(" - Earn top score for accuracy and minimal");
        append("number  of  shots  used  and  you  will  be");
        append("awarded  the  Gold  Medal  of  Honor after");
        append("each level!");
        append();
        append("    Controls:");
        append();
        append("- Drag back the Big Angry. The more you");
        append("drag  it,  the  farther  it  will  throw   the");
        append("Little  Angry  (strongest when Big Angry");
        append("is red with rage).");
        append("- And  if  you  drag  Big  Angry  back just a");
        append("little,  little,  Big  Angry's   face  will  not");
        append("be as angryand not as red, and the throw");
        append("will be weaker.");
        append("- Pay attention to arrows that appear after");
        append("dragging   Big   Angry  -  they   show   the");
        append("trajectory of your future shot (adjust the");
        append("trajectory by dragging up or down).");
        append("- View the Pork  camp and return back to");
        append("Angry  by  Arkantoz S60 screen back and");
        append("forth.");
        append();
        append(" Angry Birds!");
        append();
        append("                                      ---    ");
        append("                         Angry  Birds    ");
        append();
        append("                                Arkantoz ");
        append();
        append("                               Version 2.0");
        add(btBack, 257, 310);
        add(lbAbout, 70, 105);
    }

    public final void append(String s)
    {
        lbAbout.append(s);
    }

    public final void append()
    {
        append("");
    }

    public void onPaint(Graphics g)
    {
        Textures.mainMenuBackground.draw(g, 0, 0);
        Textures.selectScenarioMainBackground.draw(g, 33, 0);
        Textures.aboutCaption.drawFlag(g, 321, 72, 3);
        super.onPaint(g);
        Textures.aboutTop.draw(g, 70, 105);
        Textures.aboutDown.draw(g, 70, 290);
    }

    public static AboutScreen getInstance()
    {
        if(instance == null)
            instance = new AboutScreen();
        return instance;
    }

    public void onIdle()
    {
        if(lbAbout != null)
            lbAbout.onIdle();
        sleep(30L);
    }

    private static AboutScreen instance;
    private boolean inertion;
    private CustomTextBox lbAbout;


}
Agora, esse é o script modificado.
package com.ximad.pvn.screens;

import com.ximad.pvn.engine.*;
import com.ximad.pvn.game.Textures;
import java.util.Vector;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

// Referenced classes of package com.ximad.pvn.screens:
//            HomeScreen

public class AboutScreen extends UiScreen
{
    class CustomTextBox extends Field
    {

        public void onPaint(Graphics g)
        {
            g.setColor(fontColor);
            g.setFont(Font.getFont(0, 0, 16));
            g.clipRect(left, top, width, height);
            for(int i = 0; i < strings.size(); i++)
            {
                int y = (top + i * fontHeight) - scrollPosition;
                if(y <= top + height && y + fontHeight >= top)
                {
                    String s = (String)strings.elementAt(i);
                    g.drawString(s, left, y, 20);
                }
            }

        }

        public void onIdle()
        {
            if(inertion && begin > 10)
            {
                if(delta > 0)
                    scrollPosition -= speed * 2;
                else
                if(delta < 0)
                    scrollPosition += speed * 2;
                if(scrollPosition < 0)
                    scrollPosition = 0;
                else
                if(scrollPosition > getMaxPosition())
                    scrollPosition = getMaxPosition();
                speed--;
                if(speed == 0)
                    inertion = false;
                repaint(left, top, width, height);
            }
        }

        public void append(String text)
        {
            strings.addElement(text);
        }

        private int getMaxPosition()
        {
            return fontHeight * strings.size() - height / 2;
        }

        public boolean touchEvent(int touchEventType, int eventX, int eventY)
        {
            boolean out = false;
            if(eventX < left || eventX > left + width || eventY < top || eventY > top + height)
                out = true;
            switch(touchEventType)
            {
            default:
                break;

            case 2: // '02'
                if(out)
                    return false;
                SCROLL = true;
                lastEventY = eventY;
                begin = eventY;
                inertion = false;
                break;

            case 1: // '01'
                SCROLL = false;
                if(delta > 1 || delta < -1)
                {
                    inertion = true;
                    speed = 10;
                }
                begin = eventY - begin;
                if(begin < 0)
                    begin *= -1;
                break;

            case 3: // '03'
                if(!SCROLL)
                    return false;
                delta = eventY - lastEventY;
                scrollPosition -= delta;
                lastEventY = eventY;
                if(scrollPosition < 0)
                    scrollPosition = 0;
                else
                if(scrollPosition > getMaxPosition())
                    scrollPosition = getMaxPosition();
                repaint(left, top, width, height);
                break;
            }
            return !out;
        }

        private Vector strings;
        private int fontHeight;
        private int fontColor;
        private boolean SCROLL;
        private int lastEventY;
        private int scrollPosition;
        private int delta;
        private int speed;
        private int begin;

        private CustomTextBox(int width, int height, int textColor)
        {
            strings = new Vector();
            this.width = width;
            this.height = height;
            fontHeight = Font.getDefaultFont().getHeight();
            fontColor = textColor;
        }

    }


    public AboutScreen()
    {
        inertion = false;
        CustomButton btBack = new CustomButton(Textures.back, 0, 1) {

            protected void touchAction()
            {
                Application.setScreen(HomeScreen.getInstance());
            }

        }
;
        lbAbout = new CustomTextBox(490, 200, 0x56290f);
        append();
        append("    There's an old feud between Angry  and");
        append("Pork,   so old that no one remembers");
        append();
        append("                             what started it");
        append();
        append("    Regardless, the fighting rages on to this");
        append("day,  and  it's  brought  to  your  Symbian");
        append("device  by  Arkantoz Angry Birds  in  their");
        append("struggle  (because  they  are  cuter  than");
        append("Pork)   ");
        append("    Command  Angry   and  destroy  the");
        append("camps of ruthless Pork  killers to defend");
        append("Angry ' homeland.");
        append();
        append("    Game objective:");
        append();
        append(" - Complete each level by clearing it of all");
        append("Pork    with  minimal  number  of  shots!");
        append(" - Earn top score for accuracy and minimal");
        append("number  of  shots  used  and  you  will  be");
        append("awarded  the  Gold  Medal  of  Honor after");
        append("each level!");
        append();
        append("    Controls:");
        append();
        append("- Drag back the Big Angry. The more you");
        append("drag  it,  the  farther  it  will  throw   the");
        append("Little  Angry  (strongest when Big Angry");
        append("is red with rage).");
        append("- And  if  you  drag  Big  Angry  back just a");
        append("little,  little,  Big  Angry's   face  will  not");
        append("be as angryand not as red, and the throw");
        append("will be weaker.");
        append("- Pay attention to arrows that appear after");
        append("dragging   Big   Angry  -  they   show   the");
        append("trajectory of your future shot (adjust the");
        append("trajectory by dragging up or down).");
        add(btBack, 257, 310);
        add(lbAbout, 70, 105);
    }

    public final void append(String s)
    {
        lbAbout.append(s);
    }

    public final void append()
    {
        append("");
    }

    public void onPaint(Graphics g)
    {
        Textures.mainMenuBackground.draw(g, 0, 0);
        Textures.selectScenarioMainBackground.draw(g, 33, 0);
        Textures.aboutCaption.drawFlag(g, 321, 72, 3);
        super.onPaint(g);
        Textures.aboutTop.draw(g, 70, 105);
        Textures.aboutDown.draw(g, 70, 290);
    }

    public static AboutScreen getInstance()
    {
        if(instance == null)
            instance = new AboutScreen();
        return instance;
    }

    public void onIdle()
    {
        if(lbAbout != null)
            lbAbout.onIdle();
        sleep(30L);
    }

    private static AboutScreen instance;
    private boolean inertion;
    private CustomTextBox lbAbout;


}
Apenas foi removido as seguintes linhas:
append("- View the Pork  camp and return back to");
        append("Angry  by  Arkantoz S60 screen back and");
        append("forth.");
        append();
        append(" Angry Birds!");
        append();
        append("                                      ---    ");
        append("                         Angry  Birds    ");
        append();
        append("                                Arkantoz ");
        append();
        append("                               Version 2.0");

E não compila... se eu modifica com o Cavaj da erro na hora de executar o jogo e com o NetBeans nem chega a compilar, tentei também compilar com o javac pelo Prompt, da erro...

Editado por xXxVSNxXx
Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,3k
×
×
  • Criar Novo...