leo leo CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 21
Added by leo leo over 1 year ago

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)

Brad Parks RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 9
Added by Brad Parks over 1 year ago

Hi Leo.... Looks cool... Thanks for the work!

BTW, is your game Rolly Poly made with Cocos2dx and Marmalade?

leo leo RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 21
Added by leo leo over 1 year ago

Yes

Zhe Wang RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 1642
Location Amoy, China
Added by Zhe Wang over 1 year ago

Oh, perhaps it's the first cocos2d-x game using Marmalade platform.

Enjoy Coding, Enjoy Life.

leo leo RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 21
Added by leo leo over 1 year 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

Brad Parks RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 9
Added by Brad Parks over 1 year 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!

leo leo RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 21
Added by leo leo over 1 year 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.

winipcfg winipcfg RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 56
Added by winipcfg winipcfg over 1 year 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.

leo leo RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 21
Added by leo leo over 1 year 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)

leo leo RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 21
Added by leo leo over 1 year 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)

Zhe Wang RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 1642
Location Amoy, China
Added by Zhe Wang over 1 year ago

I've added a link to this topic in sticky FAQ.

Enjoy Coding, Enjoy Life.

p0o0q Idiot RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 2
Added by p0o0q Idiot over 1 year 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)
Posts 83
Added by 小 苏 over 1 year ago

thank you so much ... it's very useful for me

p0o0q Idiot RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 2
Added by p0o0q Idiot over 1 year ago

I fixed the problem. Thanks.

winipcfg winipcfg RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 56
Added by winipcfg winipcfg 11 months ago

This class does not work in cocos2d-x 2.0 version.

Jesus Bosch RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 366
Location Catalonia
Added by Jesus Bosch 29 days ago

it shouldnt be that hard to upgrade

Check my latest cocos2dx game (iPad): Three Little Pigs (free) https://itunes.apple.com/au/app/three-little-pigs-learn-while/id578624548?mt=8 Twitter: @jboschaiguade

Jose Antonio Andujar RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 82
Location Spain
Added by Jose Antonio Andujar 11 days ago

http://www.jandusoft.com
More than 7m downloads of my first game "Guess the Character"

Csongor Fokt RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 1
Added by Csongor Fokt 10 days ago

I have some trouble with CCBlade.cpp

CCBlade* pRet = new CCBlade(filePath, stroke, pointLimit);

Allocating an object of abstract class type 'CCBlade'

Can U help me pls ?:) THX!

Jose Antonio Andujar RE: CCBlade (Slash effect like in Fruit Ninja) has been ported to Cocos2d-x (tested in Marmalade platform)
Posts 82
Location Spain
Added by Jose Antonio Andujar 10 days ago

use my version of CCBlade

https://github.com/jandujar/CCBlade.git

And don't forget that you need to create a TouchTrailLayer, not a CCBlade.

TouchTrailLayer *layer = TouchTrailLayer::create();
addChild(layer);

http://www.jandusoft.com
More than 7m downloads of my first game "Guess the Character"


(1-18/18)