Tag Info

Hot answers tagged

15

Dialogue could be provided in any form/structure you wish it depends on how you parse the information that makes the difference. I will provide you with a basic XML syntax to get you started without understanding your games structure or language I afraid i cant provide an implementation. <?xml version="1.0" encoding="UTF-8"?> <npcs> ...


8

I won't write the code for you, but I can put forth a conceptual path forward. Assuming your text is displayed in a string, it is possible to iterate through the character array that makes up that string. The goal here is to print each character individually (or however many at a time you want) separated by a delta time. When you think about it, this isn't ...


8

You need to use SpriteFont.MeasureString. Vector2 textSize = mySpriteFont.MeasureString("Hello World"); Vector2 center = textSize / 2; The x component of textSize represents the width of the measured string while the y component represents the height.


7

There are a lot of ways - depending on what you want... Like everywhere else, there isn't something like "the best solution". Which plattform is your target? Which language are you using? What is about text resizing/rotation - is it necessary? Do you need to be able to render TrueTypeFonts? Whats about Multilanguage/Unicode? How do you want to store your ...


7

ID3DXFont can be used to render 2D text, and D3DXCreateText can be used to generate a 3D text mesh you could render as well. In general I would think the 2D approach is preferable, unless you want the text to do something odd like spin in 3D space. To find the appropriate place to start rendering the text (for the 2D case), you'll want to use the ...


6

You need to modify your model so that the UV (texture) coordinates place the texture at the correct location. It's possible that setting the texture address mode to clamp may (sort-of) solve your issue. But this also depends on your model having the correct UV coordinates to make it work. GraphicsDevice.SamplerStates[0] = SamplerState.LinearClamp; (The ...


5

The Problem is that you draw your text on the screen and then blit the doublebuffer over that. Simply change the first argument to textprintf_centre_ex from screen to buffer and it works like a charm.


5

If you want to use bitmap fonts, you can't go far wrong with the Angelcode Bitmap Font Generator: http://www.angelcode.com/products/bmfont/ It converts a truetype font to one or more textures (with nicely packed glyphs), and outputs a little file containing the UVs and spacings (I find that the XML output is particularly easy to work with, and the quality ...


5

In the games I've worked on, we restricted the subset of characters used for Chinese, Japanese, and Korean (together referred to as CJK) to only those required to display the text in the game. In other words, we didn't attempt to cram in every possible character; we just took the database of CJK text from our localization teams, did a pass over it to find ...


4

You should generally prefer structured data (XML) over scripts at every opportunity. The biggest reason for this is tool support. You can make a dialog editor for a structured format, which supports internationalization, dialog branching, testing a debugging of dialog trees, deadend and infinite loop detection in trees, etc. For a script, the only thing ...


4

Although XML is more predictable, kinda have a defined structure and all that. I would go with scripts. Rolling your own language(if you have the time, but usually this is not the best choice), or even implementing one. There are LOTS of script languages out there, they're all nice, some examples: Squirrel, Lua, Angel Script, Python, and many many many ...


4

If you want to do it the old-fashioned way, then yes, you can use it in a grid. But if you want to use any kind of variable or half-width characters, like writing 5 instead of 5, then you'll need to get off the grid. The characters are all the same width anyway so if you're not using any non-Asian characters then it should align by itself. I don't think ...


4

I think, without a library, this would require quite a few steps, but it is certainly possibly. First convert the letter to a polygon (look at the bitmap to polygon algorithms) and then that polygon to a set of triangles using a technique that supports holes in the polygon, see this wiki page. You now have a flat model built out of triangles. Now draw the ...


4

The way I handled this in my simple textbox UI element was to use a scissor rectangle (as Nicolas Bolas said while I was writing this :P). Here's the basic idea: First off, create a RasterizerState field in whatever class does the drawing of the text like so: RasterizerState _rasterizerState = new RasterizerState() { ScissorTestEnable = true }; ...


3

In my engine, I use a dynamic vertex buffer for batching up text data (each character == 1 vertex) and do point-to-quad expansion in geometry shader. As far as I know, glVertex*, glNormal*, glTexCoord* are considered obsolete (like display lists) and are not recommended to use. This gives a comprehensive overview of various OpenGL-based text rendering ...


3

If you want to clip things to a certain region, you use the scissor box. It's a property of the GraphicsDevice: GraphicsDevice.ScissorTestEnable and either RenderState.ScissorRectangle pre-XNA 4.0 or RasterizerState.ScissorTestEnable in XNA 4.0. You don't need to measure text for it; just set the scissor box to the area you want to clip to. You can draw all ...


3

You will have to manually get the size of the screen and scale down the requested text size.


3

There is also a research article from Microsoft Research by Loop and Blinn, on rendering resolution independent curves using shaders. It suggests using the presented technique to render TrueType text in a resolution independent fashion.


3

You can use D3DXCreateText to create a text "mesh", which you can then render however you like.


3

One thing I have seen often is highlighting key words like places, a macguffin to collect and key characters to talk to next. this allows a player who is just skimming to stop and reread the context consider having a fortuneteller character who gives more direct hints, just someone who will be always available to talk to maybe in the home town maybe ...


3

Given SpriteFont font; Do this: Vector2 size = font.MeasureString("Your String Here");


3

What's happening is you're clearing the screen after drawing the text. So this window.draw(text); window.clear(sf::Color::Green); should be this window.clear(sf::Color::Green); window.draw(text); If it still doesn't display anything, you definitely need to set a font!


3

To turn off antialiasing, all you have to do is change your sampler state to SamplerState.PointClamp in your spriteBatch.Begin() call. Here's a short code example: spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, null)); // Draw text here using DrawString spriteBatch.End(); ...


2

A popular framework is Crazy Eddie's GUI. But whilst that is appealing, its not unusual to roll your own (and perhaps regret it as the scope increases later ;)) Its normal to have your glyphs on bitmaps and then draw the bitmaps using OpenGL. Sometimes you show transient text that might only appear for a handful of frames. Just using GL_QUADS+glVertex ...


2

In your code flow, you are drawing the "Pause" text immediately when the player presses p. Later on in the same frame, you draw the other sprites. Pygame blit operations always draw on top of what has already been drawn. If you want the pause text to appear above everything else in the game environment, you'll have to move the code that blits it to a ...


2

Support for this was added in Phaser 2.1.2. Please see the Text.addColor method.


2

The simple way to do this is to have two objects and then use instance_change() two swap into the next object when the countdown finishes. Example: if (countdown <= 0) { instance_change(obj_go, true); }


2

I'm using the freetype library (http://www.freetype.org/) to load glyphs from freetype fonts and then use bin packing to generate a glyph texture/atlas during runtime, similar to how freetype-gl does it (https://code.google.com/p/freetype-gl/). When the game is initialized, I generate a glyph atlas with the printable characters from the ASCII range. This ...


2

Ok so to answer my own question, it turns out I'm an idiot and overlooked something really simple. The code in my question works perfectly, but I never set the text renderer's projection matrix. To make it work, in the resize method I added the following code: renderer.enable(gl, true); renderer.reshapeOrtho(width, height, 0.1f, 1000.0f); ...



Only top voted, non community-wiki answers of a minimum length are eligible