public bool initWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D texture) { this.position = CCPoint.CCPointZero; this.anchorPoint = CCPoint.CCPointZero; this.isRelativeAnchorPoint = false; this.m_bStartingPositionInitialized = false; this.m_tPositionR = CCPoint.CCPointZero; this.m_bFastMode = true; this.m_fMinSeg = (minSeg == -1f ? stroke / 5f : minSeg); CCMotionStreak mFMinSeg = this; mFMinSeg.m_fMinSeg = mFMinSeg.m_fMinSeg * this.m_fMinSeg; this.m_fStroke = stroke; this.m_fFadeDelta = 1f / fade; this.m_uMaxPoints = (int)(fade * 60f) + 2; this.m_uNuPoints = 0; this.m_pPointState = new float[this.m_uMaxPoints]; this.m_pPointVertexes = new CCPoint[this.m_uMaxPoints]; this.m_pVertices = new ccVertex2F[this.m_uMaxPoints * 2]; this.m_pTexCoords = new ccTex2F[this.m_uMaxPoints * 2]; this.m_pColor = new ccColor4B[this.m_uMaxPoints * 2]; this.m_tBlendFunc.src = 770; this.m_tBlendFunc.dst = 771; this.Texture = texture; this.Color = color; CCMotionStreak cCMotionStreak = this; base.schedule(new SEL_SCHEDULE(cCMotionStreak.update)); return(true); }
public static CCMotionStreak create(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D texture) { CCMotionStreak pRet = new CCMotionStreak(); if (pRet.initWithFade(fade, minSeg, stroke, color, texture)) { return pRet; } return null; }
public static CCMotionStreak create(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D texture) { CCMotionStreak pRet = new CCMotionStreak(); if (pRet.initWithFade(fade, minSeg, stroke, color, texture)) { return(pRet); } return(null); }
public static CCMotionStreak create(float fade, float minSeg, float stroke, ccColor3B color, string path) { CCMotionStreak cCMotionStreak = new CCMotionStreak(); if (cCMotionStreak.initWithFade(fade, minSeg, stroke, color, path)) { return(cCMotionStreak); } return(null); }
public override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); // the root object just rotates around m_root = CCSprite.spriteWithFile(s_pPathR1); addChild(m_root, 1); m_root.position = (new CCPoint(s.width / 2, s.height / 2)); // the target object is offset from root, and the streak is moved to follow it m_target = CCSprite.spriteWithFile(s_pPathR1); m_root.addChild(m_target); m_target.position = (new CCPoint(100, 0)); // create the streak object and add it to the scene m_streak = CCMotionStreak.streakWithFade(2f, 3f, 32f, new ccColor3B(0, 255, 0), s_streak); addChild(m_streak); // schedule an update on each frame so we can syncronize the streak with the target schedule(onUpdate); CCActionInterval a1 = CCRotateBy.actionWithDuration(2, 360); CCAction action1 = CCRepeatForever.actionWithAction(a1); CCActionInterval motion = CCMoveBy.actionWithDuration(2, new CCPoint(100, 0)); m_root.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(motion, motion.reverse())))); m_root.runAction(action1); CCActionInterval colorAction = CCRepeatForever.actionWithAction((CCActionInterval)CCSequence.actions( CCTintTo.actionWithDuration(0.2f, 255, 0, 0), CCTintTo.actionWithDuration(0.2f, 0, 255, 0), CCTintTo.actionWithDuration(0.2f, 0, 0, 255), CCTintTo.actionWithDuration(0.2f, 0, 255, 255), CCTintTo.actionWithDuration(0.2f, 255, 255, 0), CCTintTo.actionWithDuration(0.2f, 255, 0, 255), CCTintTo.actionWithDuration(0.2f, 255, 255, 255) )); m_streak.runAction(colorAction); /* CCActionInterval *colorAction = CCRepeatForever::create((CCActionInterval *)CCSequence::create( CCTintTo::create(0.2f, 255, 0, 0), CCTintTo::create(0.2f, 0, 255, 0), CCTintTo::create(0.2f, 0, 0, 255), CCTintTo::create(0.2f, 0, 255, 255), CCTintTo::create(0.2f, 255, 255, 0), CCTintTo::create(0.2f, 255, 0, 255), CCTintTo::create(0.2f, 255, 255, 255), NULL)); streak->runAction(colorAction); */ }
public override void onEnter() { base.onEnter(); this.isTouchEnabled = true; CCSize s = CCDirector.sharedDirector().getWinSize(); // create the streak object and add it to the scene m_streak = CCMotionStreak.streakWithFade(3, 3, 64, new ccColor3B(255, 255, 255), s_streak); addChild(m_streak); m_streak.position = (new CCPoint(s.width / 2, s.height / 2)); }
public static CCMotionStreak streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D texture) { return(CCMotionStreak.create(fade, minSeg, stroke, color, texture)); }
public static CCMotionStreak Create(float fade, float minSeg, float stroke, CCColor3B color, CCTexture2D texture) { var pRet = new CCMotionStreak(); pRet.InitWithFade(fade, minSeg, stroke, color, texture); return pRet; }
public static CCMotionStreak Create(float fade, float minSeg, float stroke, CCColor3B color, string path) { var pRet = new CCMotionStreak(); pRet.InitWithFade(fade, minSeg, stroke, color, path); return pRet; }
public override void update(float delta) { int num; int i; VertexPositionColorTexture vertexPositionColorTexture; VertexPositionColorTexture vertexPositionColorTexture1; if (!this.m_bStartingPositionInitialized) { return; } if (this.m_pVerticesPCT == null) { this.m_pVerticesPCT = new VertexPositionColorTexture[(this.m_uNuPoints + 1) * 2]; } if (this.m_uNuPoints * 2 > (int)this.m_pVerticesPCT.Length) { VertexPositionColorTexture[] vertexPositionColorTextureArray = new VertexPositionColorTexture[(this.m_uNuPoints + 1) * 2]; this.m_pVerticesPCT.CopyTo(vertexPositionColorTextureArray, 0); this.m_pVerticesPCT = vertexPositionColorTextureArray; } delta = delta * this.m_fFadeDelta; int num1 = 0; for (i = 0; i < this.m_uNuPoints; i++) { VertexPositionColorTexture mPVerticesPCT = this.m_pVerticesPCT[i]; VertexPositionColorTexture mPVerticesPCT1 = this.m_pVerticesPCT[i * 2]; this.m_pPointState[i] = this.m_pPointState[i] - delta; if (this.m_pPointState[i] > 0f) { int num2 = i - num1; if (num1 <= 0) { num = num2 * 2; } else { this.m_pPointState[num2] = this.m_pPointState[i]; this.m_pPointVertexes[num2] = new CCPoint(this.m_pPointVertexes[i]); int num3 = i * 2; num = num2 * 2; this.m_pVertices[num] = new ccVertex2F(this.m_pVertices[num3]); this.m_pVertices[num + 1] = new ccVertex2F(this.m_pVertices[num3 + 1]); this.m_pColor[num] = new ccColor4B(this.m_pColor[num3]); this.m_pColor[num + 1] = new ccColor4B(this.m_pColor[num3 + 1]); this.m_pVerticesPCT[num] = this.m_pVerticesPCT[num3]; this.m_pVerticesPCT[num + 1] = this.m_pVerticesPCT[num3 + 1]; } byte mPPointState = (byte)(this.m_pPointState[num2] * 255f); this.m_pColor[num].a = mPPointState; this.m_pColor[num + 1].a = mPPointState; if (this.m_pVertices[num] != null) { vertexPositionColorTexture = new VertexPositionColorTexture(this.m_pVertices[num].ToVector3(), this.m_pColor[num].XNAColor, this.m_pTexCoords[num].ToVector2()); this.m_pVerticesPCT[num] = vertexPositionColorTexture; } if (this.m_pVertices[num + 1] != null) { vertexPositionColorTexture = new VertexPositionColorTexture(this.m_pVertices[num + 1].ToVector3(), this.m_pColor[num + 1].XNAColor, this.m_pTexCoords[num + 1].ToVector2()); this.m_pVerticesPCT[num + 1] = vertexPositionColorTexture; } } else { num1++; } } CCMotionStreak mUNuPoints = this; mUNuPoints.m_uNuPoints = mUNuPoints.m_uNuPoints - num1; bool flag = true; if (this.m_uNuPoints >= this.m_uMaxPoints) { flag = false; } else if (this.m_uNuPoints > 0) { bool flag1 = this.m_pPointVertexes[this.m_uNuPoints - 1].DistanceSQ(this.m_tPositionR) < this.m_fMinSeg; if (flag1 || (this.m_uNuPoints == 1 ? false : this.m_pPointVertexes[this.m_uNuPoints - 2].DistanceSQ(this.m_tPositionR) < this.m_fMinSeg * 2f)) { flag = false; } } if (flag) { this.m_pPointVertexes[this.m_uNuPoints] = new CCPoint(this.m_tPositionR); this.m_pPointState[this.m_uNuPoints] = 1f; int mUNuPoints1 = this.m_uNuPoints * 2; this.m_pColor[mUNuPoints1] = new ccColor4B(this.m_tColor); this.m_pColor[mUNuPoints1 + 1] = new ccColor4B(this.m_tColor); this.m_pColor[mUNuPoints1].a = 255; this.m_pColor[mUNuPoints1 + 1].a = 255; if (this.m_uNuPoints > 0 && this.m_bFastMode) { if (this.m_uNuPoints <= 1) { CCVertex.LineToPolygon(this.m_pPointVertexes, this.m_fStroke, this.m_pVertices, 0, 2); } else { CCVertex.LineToPolygon(this.m_pPointVertexes, this.m_fStroke, this.m_pVertices, this.m_uNuPoints, 1); } } CCMotionStreak cCMotionStreak = this; cCMotionStreak.m_uNuPoints = cCMotionStreak.m_uNuPoints + 1; } if (!this.m_bFastMode) { CCVertex.LineToPolygon(this.m_pPointVertexes, this.m_fStroke, this.m_pVertices, 0, this.m_uNuPoints); } if (this.m_uPreviousNuPoints != this.m_uNuPoints) { if (this.m_uNuPoints > this.m_uPreviousNuPoints) { int length = (this.m_uNuPoints + 1) * 2; if (length < (int)this.m_pVerticesPCT.Length) { length = (int)this.m_pVerticesPCT.Length; } VertexPositionColorTexture[] vertexPositionColorTextureArray1 = new VertexPositionColorTexture[length]; this.m_pVerticesPCT.CopyTo(vertexPositionColorTextureArray1, 0); this.m_pVerticesPCT = vertexPositionColorTextureArray1; } float single = 1f / (float)this.m_uNuPoints; for (i = 0; i < this.m_uNuPoints; i++) { this.m_pTexCoords[i * 2] = new ccTex2F(0f, single * (float)i); this.m_pTexCoords[i * 2 + 1] = new ccTex2F(1f, single * (float)i); if (this.m_pVertices[i * 2] != null) { vertexPositionColorTexture1 = new VertexPositionColorTexture(this.m_pVertices[i * 2].ToVector3(), this.m_pColor[i * 2].XNAColor, this.m_pTexCoords[i * 2].ToVector2()); this.m_pVerticesPCT[i * 2] = vertexPositionColorTexture1; } if (this.m_pVertices[i * 2 + 1] != null) { vertexPositionColorTexture1 = new VertexPositionColorTexture(this.m_pVertices[i * 2 + 1].ToVector3(), this.m_pColor[i * 2 + 1].XNAColor, this.m_pTexCoords[i * 2 + 1].ToVector2()); this.m_pVerticesPCT[i * 2 + 1] = vertexPositionColorTexture1; } } this.m_uPreviousNuPoints = this.m_uNuPoints; } }
public static CCMotionStreak streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, string path) { return(CCMotionStreak.create(fade, minSeg, stroke, color, path)); }