CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Hello everyone,
I was looking for slash effect when the user swipe his finger on screen that will look like Fruit Ninja (arrow shape getting thinner).
CCMoitionStreak wasn't very satisfying - it was too sharp in the corners, it didn't has an arrow shape and didn't get thinner.
So I found CCBlade here:
https://github.com/hiepnd/CCBlade
I ported it to C++ and test it in Marmalade platform, the results are great!
here you can see it in action in my game, Rolly Poly:
[[http://www.youtube.com/watch?v=5jHBgKSzij0]]
The code, of course, is attached. the usage is very simple - just add TouchTrailLayer::node() to your scene as a child.
Big thanks to Ngo Duc Hiep who wrote this wonderful class in the first place.
P.S - there might be a small memory leak, I didn't find it yet, if anyone will find something, please post it here.
(ignore .h and .cpp attached files, the updated version is attached - ccblade.zip)
streak1.png (1.4 kB)
CCBlade.cpp (5.4 kB)
CCBlade.h (2 kB)
TouchTrailLayer.cpp (2.6 kB)
TouchTrailLayer.h (1.6 kB)
ccblade.zip (5.8 kB)
Replies (13)
RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
-
Added by Brad Parks 7 months ago
Hi Leo.... Looks cool... Thanks for the work!
BTW, is your game Rolly Poly made with Cocos2dx and Marmalade?
RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
-
Added by leo leo 7 months ago
Yes
RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
-
Added by Walzer Wang 7 months ago
Oh, perhaps it's the first cocos2d-x game using Marmalade platform.
RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
-
Added by leo leo 7 months ago
I guess so, I started working on it when cocos2d-airplay extension wasn't official and was only a post of a forum discussions.
Btw - my game is already available for download:
http://www.roymam.com/rollypoly/getfullversion.php
RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
-
Added by Brad Parks 7 months ago
So are you planning on releasing to Android as well?
For what it's worth, I've installed the lite version of Rolly Poly on my iPhone 4 and it works great.... and the slash effect looks good too!
RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
-
Added by leo leo 7 months ago
The slash effect on the version you installed is the older one and uses CCMoitionStreak, the new one (with CCBlade) hasn't been published yet.
I'm planning to release it on Android too later, My Marmalade license currently doesn't allow it.
RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
-
Added by winipcfg winipcfg 7 months ago
I also tried to import it. However, it looks there are some defects on the code.
From original CCBlade example, it continues to be added to layer every time we want to draw a blade. It will not be destroyed or remove from parent.
Therefore, after you run the game with 900+ blades, the system crashes.
Note: You cannot delete the blade manually after it finish rendering. If you do it, the system crash instantly.
RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
-
Added by leo leo 7 months ago
you right, the blade is never deleted unless you delete the parent.
I added "getParent()->removeChild(this,true)" after the blade is faded, I used schedule to run it because when running inside the draw() function the system crash.
try it now. flie (ccblade.zip) is attached.
ccblade.zip (5.8 kB)
RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
-
Added by leo leo 7 months ago
you right, the blade is never deleted unless you delete the parent.
I added "getParent()->removeChild(this,true)" after the blade is faded, I used schedule to run it because when running inside the draw() function the system crash.
try it now. file (ccblade.zip) is attached.
ccblade.zip (5.8 kB)
RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
-
Added by Walzer Wang 7 months ago
I've added a link to this topic in sticky FAQ.
RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
-
Added by p0o0q Idiot 3 months ago
Hi,
I can compile example successfully. However, it can show Cocos2d startup image but no further action. There is no error message.
2012-02-15 19:16:59.736 Example[2668:207] cocos2d: compiled with Affine Matrix transformation in CCNode : YES
2012-02-15 19:16:59.736 Example[2668:207] cocos2d: compiled with Profiling Support: NO
2012-02-15 19:16:59.744 Example[2668:207] Retina Display Not supported
2012-02-15 19:16:59.797 Example[2668:207] cocos2d: Frame interval: 1
2012-02-15 19:16:59.800 Example[2668:207] cocos2d: surface size: 320x480
I am using Base SDK iphone device 4.0 and iPhone OS Deployment Target iPhone OS 3.2.
Would you please give me some advice to fix it?
Thanks.
p0o0q
RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
-
Added by 小 苏 3 months ago
thank you so much ... it's very useful for me
RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
-
Added by p0o0q Idiot 3 months ago
I fixed the problem. Thanks.
(1-13/13)