Skip to main content

Posts

Showing posts from June, 2020

creating a endless parallax in cocos2dx (best for endless games).

code hpp file #ifndef NMBirdParallax_hpp #define NMBirdParallax_hpp #include "cocos2d.h" #include "Box2D/Box2D.h" using namespace cocos2d ; using namespace std ; class NMBirdParallax: public cocos2d :: Node {     public :         // Constructor private to make misuse of this class difficult.          // Destructor declared and defined here.         CREATE_FUNC ( NMBirdParallax );         virtual bool init();         void drawParallax( vector < string > &backgrounds, float distanceBetween, float Speed);         void onEnter();         void onExit();     NMBirdParallax();     // Constructor declared but defined in the cpp file.     ~NMBirdParallax(){}              void update( float dt);        private :     float mov...

custom hooks in react with two example

more about custom hooks https://reactjs.org/docs/hooks-custom.html custom hooks like regular react hooks so you can create your own hooks and make them reusable entities. one note hook name should start with the use keyword. working link https://stackblitz.com/edit/react-wk6ueh import   React ,   {   Component , useEffect , useState  }   from   'react' ; import   {  render  }   from   'react-dom' ; import   Hello   from   './Hello' ; import   './style.css' ; //usefetchData hook uses to fetch data from any api  const  usefetchData =( url )=>{    //check status data is loaded or not    const    [ status , setStatus ]= useState ( false )    //set data when its loaded sucessfully    const    [ data , setData ]= useS...