Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I move a specific child in CCScrollLayer?
    primarykey
    data
    text
    <p>I am working to convert my CCScrollLayer.cpp code into more of a CCPicker code. In CCScrollLayer, I've defined a baselayer (CCColorLayer) to hold all of the menu objects. I also have a border that holds the ScrollLayer (using glScissor) called "overlay" that I want to be completely static.</p> <h2>In Objective C:</h2> <pre><code>... self.baseLayer = [CCLayerColor layerWithColor:(ccColor4B){150,150,150,0} width:s.width height:imgSize.height * numPages]; for (int i=0; i &lt; [arrayPages count]; i++) { CCNode* n = arrayPages[i]; n.position = ccp(s.width/2, s.height/2 + i * (imgSize.height + padding)); [baselayer addChild:n]; } baseLayer.position = ccp(-s.width/2, -s.height/2 - s.height * currentPage); [self addChild:baselayer]; ... - (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event { CGPoint n = [self convertTouchToNodeSpace:touch]; baselayer.position = ccp(touchStartedbaseLayerPosition.x, touchStartedbaseLayerPosition.y + n.y - touchStartedPoint.y); } </code></pre> <h2>In C++</h2> <pre><code>... overlay=new CCSprite(); overlay-&gt;initWithFile("overlay.png"); overlay-&gt;setPosition(ccp(300,300)); overlay-&gt;autorelease(); CCLayerColor* baselayer = new CCLayerColor(); baselayer-&gt;initWithColor(ccc4(255, 255, 255,255)); baselayer-&gt;setOpacity(255); baselayer-&gt;setContentSize(CCSizeMake(s.width/10, (layers-&gt;count()*scrollWidth))); baselayer-&gt;setPosition(s.width*.41,300); baselayer-&gt;autorelease(); // Loop through the array and add the screens unsigned int i; for (i=0; i&lt;layers-&gt;count(); i++) { CCLayer* l = static_cast&lt;CCLayer*&gt;(layers-&gt;objectAtIndex(i)); l-&gt;setAnchorPoint(ccp(0,0)); l-&gt;setPosition(ccp(s.width/40,(i*scrollWidth))); baselayer-&gt;addChild(l); } this-&gt;addChild(baselayer,1); this-&gt;addChild(overlay,1); ... void CCScrollLayer::ccTouchMoved(CCTouch *touch, CCEvent *withEvent) { CCPoint touchPoint = touch-&gt;getLocation(); // Get the touch position touchPoint = this-&gt;getParent()-&gt;convertToNodeSpace(touchPoint); baselayer-&gt;setPosition(ccp(0,(-(currentScreen-1)*scrollWidth)+(touchPoint.y-startSwipe))); } </code></pre> <p>I'm not sure what I'm doing wrong, but as soon as I try to start scrolling, I get a fatal error in the touchdispatcher</p> <blockquote> <pre><code> case CCTOUCHMOVED: pHandler-&gt;getDelegate()-&gt;ccTouchMoved(pTouch, pEvent); </code></pre> </blockquote> <p>I'm guessing I'm missing something simple here. Can you point me in the write direction?</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