Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - qxtianlong

Pages: [1]
1
General / display Chinese characters ???
« on: November 07, 2009, 04:28:56 am »
logo.h
Code: [Select]

sf::Font            mFont1;
sf::Font            mFont2;
sf::String          mText1;
sf::String          mText2;

logo.cpp

Code: [Select]


void Logo::Init()
{
// load background Image
if (!mBgImage.LoadFromFile("Data\\gfx\\secondlife.png"))
{
// Error...
cout << "[!] Wasn't able to load the secondlife.png File" << endl;
}

// link background image to sprite
mBgSprite.SetImage(mBgImage);

mBgSprite.SetPosition((WINWIDTH-mBgImage.GetWidth())/2,(WINHEIGHT-mBgImage.GetHeight())/2);

if(!mFont1.LoadFromFile("Data\\fonts\\simkai.ttf",30,L"        SecondLife Present"))
{
cout << "[!] Wasn't able to load the simkai.ttf File" << endl;
}

if(!mFont2.LoadFromFile("Data\\fonts\\simkai.ttf",30,L"第二人生游戏开发俱乐部发行"))
{
cout << "[!] Wasn't able to load the simkai.ttf File" << endl;
}

int start = (WINHEIGHT - mBgImage.GetHeight()) / 2 + mBgImage.GetHeight() + 1;

mText1.SetFont(mFont1);
mText1.SetText(L"        SecondLife Present");
mText1.SetSize(18);
mText1.SetPosition(WINHEIGHT/2,start+16);
mText1.SetColor(sf::Color(0,255,0));

mText2.SetFont(mFont2);
mText2.SetText(L"第二人生游戏开发俱乐部发行");
mText2.SetSize(18);
mText2.SetPosition(WINHEIGHT/2,start+48);
mText2.SetColor(sf::Color(0,255,0));


mClock.Reset();
}


simkai.ttf is chinese font, mText1 and mText2 is chinese characters.

Code: [Select]

void Logo::Draw(sf::RenderWindow &Window)
{
Window.Clear();

Window.Draw(mBgSprite);

Window.Draw(mText1);
Window.Draw(mText2);

if( i < 20 )
i = 0;
else
i -= 10;

Window.Draw(sf::Shape::Rectangle(0, 0, WINWIDTH, WINHEIGHT, sf::Color(0,0,0,i)));


Window.Display();
}



The above code is correct, if not correct please give me an example.

My English is not good[/code]

2
Graphics / help link 2001
« on: November 04, 2009, 06:48:37 am »
Code: [Select]
#include <SFML/Audio.hpp>
 #include <SFML/Graphics.hpp>
 
#pragma comment(lib,"sfml-main-d.lib")
#pragma comment(lib,"sfml-system-d.lib")
#pragma comment(lib,"sfml-window-d.lib")
#pragma comment(lib,"sfml-graphics-d.lib")
#pragma comment(lib,"sfml-audio-d.lib")


 int main()
 {
     // Create the main window
     sf::RenderWindow App(sf::VideoMode(800, 600,32), "SFML");
 
     // Load a sprite to display
     sf::Image Image;
     if (!Image.LoadFromFile("data/gfx/intro.jpg"))
         return EXIT_FAILURE;
     sf::Sprite Sprite(Image);
 
     // Create a graphical string to display
     sf::Font Arial;
     if (!Arial.LoadFromFile("data/fonts/simkai.ttf"))
         return EXIT_FAILURE;
     
sf::String Text("Hello SFML", Arial, 50);
 
     // Load a music to play
     sf::Music Music;
     if (!Music.OpenFromFile("data/sfx/main.ogg"))
         return EXIT_FAILURE;

     // Play the music
     Music.Play();
 
     // Start the game loop
     while (App.IsOpened())
     {
         // Process events
         sf::Event Event;
         while (App.GetEvent(Event))
         {
             // Close window : exit
             if (Event.Type == sf::Event::Closed)
                 App.Close();
         }
 
         // Clear screen
         App.Clear();
 
         // Draw the sprite
         App.Draw(Sprite);
 
         // Draw the string
         App.Draw(Text);
 
         // Update the window
         App.Display();
     }
 
     return EXIT_SUCCESS;
 }



Quote
main.obj : error LNK2001: 无法解析的外部符号 "private: static unsigned int * sf::Font::ourDefaultCharset" (?ourDefaultCharset@Font@sf@@0PAIA)
E:\独立制作\Test\Debug\Test.exe : fatal error LNK1120: 1 个无法解析的外部命令

3
General / I am from china,Help me
« on: November 04, 2009, 04:01:20 am »
How does this engine support Chinese?

Pages: [1]
anything