Note that there are some explanatory texts on larger screens.

plurals
  1. POExplaination of RayWenderlich's CCParallaxNodeExtras.h
    primarykey
    data
    text
    <p>I was going through the <a href="http://www.raywenderlich.com/33752/cocos2d-x-tutorial-for-ios-and-android-space-game" rel="nofollow">Ray Wenderlich's Space Game</a> tutorial for android. Great Tutorial. I am an intermediate C++ programmer and I am trying to understand what's happening inside here. Just to understand I've rewritten it. Removing macros.</p> <pre><code>class CCPointObject: CCObject { protected: CCPoint m_tRatio; CCPoint m_tOffset; CCNode *m_pChild; public: virtual CCPoint getRatio() const { CCLog("getRatio_CALLED"); return m_tRatio; } virtual void setRatio(CCPoint newRatio) { CCLog("setRatio_CALLED"); m_tRatio = newRatio; } . .. ... // similarly getChild/setChild/getOffset/setOffset is defined. The code works perfectly fine. }; void CCParallaxNodeExtras::incrementOffset(CCPoint offset,CCNode* node) { for( unsigned int i = 0; i &lt; m_pParallaxArray-&gt;num; i++) { CCPointObject *point = (CCPointObject *)m_pParallaxArray-&gt;arr[i]; CCNode * curNode = point-&gt;getChild(); if( curNode-&gt;isEqual(node) ) { point-&gt;setOffset( ccpAdd(point-&gt;getOffset(), offset) ); break; } } } </code></pre> <p>MY DOUBTS:</p> <ul> <li>when point is initialized (by casting CCObject* to CCPointObject*), how m_tOffset, m_tRatio and m_pChild is initialized to actual values of that Object's offset and ratio ?</li> <li>I've given CCLogs in setOffset/getOffset functions of CCPointObject, but they have been never called so which setOffset/getOffset is called ? As CCPointObject is inherited from CCObject so I thought, might be CCObject's setOffset/getOffset is being called but, as i checked, there is no setOffset/getOffset declared in CCObject.</li> <li><p>I looked in to ccParallaxNode.h and its there,</p> <p>//array that holds the offset / ratio of the children</p> <p>CC_SYNTHESIZE(struct _ccArray *, m_pParallaxArray, ParallaxArray)</p> <p>and _ccArray has CCObject** that means Array of CCObjects and CCObject does not have any variable as m_tOffset/m_tRatio or m_pChild so, where actually the offset/ratio is stored ?</p></li> </ul> <p>These doubts are driving me nuts. Please help !!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload