Main Menu


Sponsored Links

  


  
  
Web Cartoon Maker: a Fun Way to Learn C++ Contents Previous Next

Customizing a Character's Decals

You already know how to change a decal image of a character's part using a SetDecal method. But you were able to change only between existing registered decals like "DEFAULT" or "WINK1" . It is also possible to register a brand new decal or re-register an existing decal using a Part's RegisterDecal method. This method accepts two string parameters. The first one is a decal name (like "DEFAULT" or "WINK1" or any other name) and the second one is a path to an actual image. This MUST BE A FULLY QUALIFIED LOCAL PATH TO AN IMAGE ON YOUR HARD DRIVE like "c:\\myimage.svg" (it could also be a short path to an image in WCM character's library but you do not have direct access to these images). Please keep in mind that RegisterDecal can be used only once for every character's part. If you use it more than once then the latest instance will take precedence. When you register a part's decal you do this for the entire scene and it has effect from the beginning to the end of a cartoon scene. For example:

void Scene1 ()

{

Boy Max;

Max.SetVisible ();

Max.Head.RegisterDecal ( "MY", "c:\\myimage.svg" );

Max.Head.SetDecal ( "MY" );

Sleep (1 );

}

does exactly the same the same thing as

void Scene1 ()

{

Boy Max;

Max.SetVisible ();

Max.Head.SetDecal ( "MY" );

Max.Head.RegisterDecal ( "MY", "c:\\myimage.svg" );

Sleep (1 );

}

It may look like the second example is wrong because decal "MY" is unknown, but it works the same way because it does not matter if decal was registered before of after usage. For code readability reasons it is recommended to register decals before usage though.

You will discover some more "Register" methods soon. They all work the same way. They affect the entire cartoon scene and it does not matter when they were called. The latest call takes precedence. Also, since the scenes are function calls, the decal information is local to a given scene and given object, thus changing a decal in Scene1 will not affect Scene2 (much like stage actors never change costumes in the middle of a scene, but often do so between scenes) and will not affect another instances of the same class.

In the above example we registered a custom decal "MY" , but it is possible to re-register existing decals, even the "DEFAULT" one:

void Scene1 ()

{

Boy Max;

Max.SetVisible ();

Max.Head.RegisterDecal ( "DEFAULT", "c:\\myimage.svg" );

Sleep (1 );

}

If we re-register the "DEFAULT" decal, then we even do not need to use SetDecal , because it is set to "DEFAULT" automatically.

There is even better place to register and re-register decals. You can derive a new character from existing one and register decals in constructor:

class BoyEx : public Boy

{

public :

BoyEx () : Boy ()

{

Head. RegisterDecal ( "DEFAULT", "c:\\myimage.svg" );

}

};


Contents Previous Next
  
News

New Tales Animator Video by Alan Sturgess

Alan Sturgess shared an excellent video he made using Tales Animator! You can still download Tales Animator here. Unfortunately it is only available for Wi

...

Simple Online Character Designer

There is a prototype of simple online character designer available HERE. It is only a prototype, it does not contain many pieces yet but it can already generat

...

Book is updated

Now our book "Web Cartoon Maker: A Fun Way to Learn C++" is fully in synch with WCM 1.5! It is available for download and online reading HERE.

...

Web Cartoon Maker 1.5 is here!

Web Cartoon Maker 1.5 is finally here! You can download it HERE! Here is what was updated in version 1.5: Web Cartoon Maker Desktop Edition is now fully standal

...

read more news...


Poll