Sign in to follow this  
wqking

Tween and timeline -- create ease animation in C++ (cpgf library version 1.5.5)

Recommended Posts

wqking    761

I'm glad to announce cpgf library version 1.5.5 is release.

 

cpgf library -- free C++ open source library for reflection, serialization, Lua, Google V8 JavaScript and Python script binding, callbacks

 

Changes log:

  • Added tweening and timeline library.
  • Added generic property accessors, getter and setter.
  • Refactored meta property to reuse generic property accessors.
  • Fixed a bug that using function (not pointer) as property accessor may cause wrong address crash in VC.
  • Fixed a bug that using policy GMetaRuleExplicitThis on property setter may cause wrong argument being selected.
  • Fixed a compile error in gstdint.h in VC 2012.

Sample code to create tween animation

// Define a sprite somewhere.
FooSprite mySprite;
 
// Setup the tween
GTween & tween = GTweenList::getInstance()->createTween()
  .duration(2.0f)
  .ease(ElasticEase::easeIn())
 
  // We can use getter/setter functions
  .target(createAccessor(&mySprite, &FooSprite::getX, &FooSprite::setX), 100)
 
  // We can also use property address directly, as long as the property is public.
  .target(createAccessor(&mySprite, &FooSprite::y, &FooSprite::y), 200)
;
 
// The main tick function
void gameLoop(float frameDuration)
{
  GTweenList::getInstance()->tick(frameDuration);
}

The library web site:
http://www.cpgf.org/

 

Tween library documentation

http://www.cpgf.org/document/cpgf-tween-library.html

 

Share this post


Link to post
Share on other sites
Sign in to follow this