proton_entity_part2
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| proton_entity_part2 [2010/10/27 14:09] – created seth | proton_entity_part2 [2012/02/07 09:45] (current) – [What's the Proton way to do it?] aki | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| What is the most useful component, one that we've already used several times at once on each entity in the last tutorial? | What is the most useful component, one that we've already used several times at once on each entity in the last tutorial? | ||
| - | The answer may surprise you. | + | The answer may surprise you... we'll use an extremely simple example to contrast the "old way" with the "new way". |
| - | Traditionally in an entity system, you may have said I want to be able to fade out my entity by doing a simple **Entity:: | + | Traditionally in an entity system, you may have said //"Hey mom, I want to be able to fade out my entity by doing a simple **Entity:: |
| And you'd need to add a timer to keep track of the fade which would manipulate the alpha component when rendering. | And you'd need to add a timer to keep track of the fade which would manipulate the alpha component when rendering. | ||
| Line 10: | Line 10: | ||
| ====What' | ====What' | ||
| - | You may say, "//well, that's ok, I'll write a FadeOutComponent//" | + | You: "// |
| - | First, here is a brute force dumb way it could be done by overusing the message | + | First, here is a brute force dumb way it could be done by overusing the message manager: (but notice it does save us from needing to add any code inside the entity or any component classes, we want to keep them as pure as fresh snow) |
| <code cpp> | <code cpp> | ||
| Line 65: | Line 65: | ||
| </ | </ | ||
| - | Yeah, it's almost so simple we don't even need the FadeOutEntity() wrapper at all. | + | Yeah, it's almost so simple we don't even need the **FadeOutEntity()** wrapper at all. |
| ====Getting fancy: eInterpolateType and scheduling==== | ====Getting fancy: eInterpolateType and scheduling==== | ||
| Line 75: | Line 75: | ||
| Interpolate type is an optional setting that allows you to control how the interpolation works. | Interpolate type is an optional setting that allows you to control how the interpolation works. | ||
| - | < | + | < |
| enum eInterpolateType | enum eInterpolateType | ||
| { | { | ||
| Line 88: | Line 88: | ||
| </ | </ | ||
| If you are an animator you'll shrug and know what most of these mean already. | If you are an animator you'll shrug and know what most of these mean already. | ||
| + | ** | ||
| + | INTERPOLATE_SMOOTHSTEP** is the one you'll use the most, it's just so.. smooooooth. | ||
| - | INTERPOLATE_SMOOTHSTEP is the one you'll use the most, it's just so.. smooooooth. | + | The last two tell the engine that the **uint32** should be treated as a color. |
| - | + | ||
| - | The last two tell the engine that the uint32 should be treated as a color. | + | |
| - | The delayBeforeActionMS parm is self explanatory, | + | The **delayBeforeActionMS** parm is self explanatory, |
| - | So, finally, let's take a look at the actual FadeEntity() function in EntityUtils.cpp: | + | So, finally, let's take a look at the actual |
| <code cpp> | <code cpp> | ||
| Line 137: | Line 137: | ||
| * It allows you to specify the interpolation type | * It allows you to specify the interpolation type | ||
| * It allows you to specify a delay before starting the fade | * It allows you to specify a delay before starting the fade | ||
| + | * It let's you set what to fade to, up or down | ||
| This is a great example of how you can use basic components to do interesting things. All of the helper functions in EntityUtils.cpp work this way. | This is a great example of how you can use basic components to do interesting things. All of the helper functions in EntityUtils.cpp work this way. | ||
proton_entity_part2.1288188598.txt.gz · Last modified: by seth
