ios - Cocos2D 2.x: Running CCWave action makes sprite disappear -
i can run ccwave actions on sprites no problem, except particular instance. initialize class of mine has ccsprite add ccrendertexture. sprite made adding tile sprite textures ccrendertexture, , removing tiles. can add sprite ccrendertexture child no problem, if add ccwave function , run it, sprite disappears.
// 1: create new ccrendertexture ccrendertexture *rt = [ccrendertexture rendertexturewithwidth:width height:height]; // 2: call ccrendertexture:begin [rt beginwithclear:0 g:0 b:0 a:0]; /* loop tiles within bounding object's rectangle */ cgpoint tilecoord; for(int w = 0; w < (width / tilepxwidth); ++w){ for(int h = (height / tilepxwidth); h > 0; --h){ tilecoord = [tilecoord tilecoordforposition:ccp(x + (w * tilepxwidth), y + (h * tilepxwidth)) withmap:themap]; ccsprite *backgroundtilesprite = [self.background tileat:tilecoord]; ccsprite *copiedsprite = [ccsprite spritewithtexture:backgroundtilesprite.texture rect:backgroundtilesprite.texturerect]; [copiedsprite.texture setaliastexparameters]; copiedsprite.position = ccp(8 + (w * tilepxwidth), (8 + (h * tilepxwidth)) - 16); // 3: visit update rendertexture (rt) [copiedsprite visit]; [self.background removetileat:tilecoord]; } } // 4: call ccrendertexture:end [rt end]; // 5: create new sprite texture waterline.tilessprite = [ccsprite spritewithtexture:rt.sprite.texture]; [themap addchild:waterline.tilessprite z:[[themap layernamed:@"background"] zorder]-1]; waterline.tilessprite.flipy = yes; waterline.tilessprite.anchorpoint = cgpointzero; waterline.tilessprite.position = ccp(x,y); [waterlines insertobject:waterline atindex:waterlinenum]; // if add code below, sprite no longer shows up! id waveeffect = [ccwaves actionwithduration:25 size:cgsizemake(1,10) waves:3 amplitude:8 horizontal:no vertical:yes]; [waterline.tilessprite runaction:[ccrepeatforever actionwithaction:waveeffect]];
just few details might curious about. have transparent background in game background can run separately game when scene transitions.
some stuff in delegate:
ccglview *glview = [ccglview viewwithframe:[window_ bounds] pixelformat:keaglcolorformatrgba8 depthformat:gl_depth24_stencil8_oes preservebackbuffer:no sharegroup:nil multisampling:no numberofsamples:0]; [cctexture2d setdefaultalphapixelformat:kcctexture2dpixelformat_rgba8888]; glview.opaque = no; glclearcolor(0.0f,0.0f,0.0f,0.0f); [cctexture2d pvrimageshavepremultipliedalpha:yes];
i realized seems effect has done on spritesheet, not sprite.
Comments
Post a Comment