How to create ninja sword in Andengine

  ... discussions about development with the GLES1 branch of AndEngine.

How to create ninja sword in Andengine

Postby andgamer » Thu Oct 20, 2011 6:33 am

Hello,
I am new in Andengine. I am developing a game using Andengine. My game will use fruit ninja like sword. I am googling from last one week. But couldn't find any resource regarding create sword in Andengine. Can anyone please help me out to develop a ninja sword by Andengine ?
andgamer
 
Posts: 6
Joined: Thu Oct 20, 2011 6:28 am

Re: How to create ninja sword in Andengine

Postby jaym » Thu Oct 20, 2011 12:24 pm

Hello,

In a situation like this, you probably won't get much help unless you post smaller problems that arise while trying to create the sword effect yourself. Programming requires you to use your brain to figure out solutions and if you don't want to do that then you can always pay someone to create this for you.

There's a lot of programmers out there and while many are willing to share info and help each other out, it is nearly impossible to find one who will do your work for free. My question is have you tried to make this yet? If not, that might be a good start.
AndEngine for Android Game Development Cookbook - Based on AndEngine's latest, greatest, GLES2.0 AnchorCenter branch!
jaym
 
Posts: 690
Joined: Wed May 04, 2011 10:08 pm

Re: How to create ninja sword in Andengine

Postby badchoice » Thu Oct 20, 2011 1:07 pm

A good way to start, is add a touchlistener, and in the action.down, you create an array of rectangles
then in the move array, you put the first one where the finger is, the second one where the first was before, the third one where the second was before etc...

on the action.up event, add a thread that will keep doing this till the end, so you have a little nice delay there ;)

You can use rectangles or you own sprites.

I thinks this may be a good aproach to start with.
badchoice
 
Posts: 91
Joined: Wed Apr 06, 2011 9:23 am
Location: Barcelona

Re: How to create ninja sword in Andengine

Postby drjava72 » Thu Oct 20, 2011 2:38 pm

IOnSceneTouchListener can help you

you can see that if finger went over any sprite. just an idea
Best Regards,
drJava72
drjava72
 
Posts: 287
Joined: Fri Apr 29, 2011 8:03 am

Re: How to create ninja sword in Andengine

Postby andgamer » Thu Oct 20, 2011 9:01 pm

Thanks to all for quick reply.
I tried IOnSceneTouchListener and can detect touch up/down/move. I Heard from someone that openGL's triangle strips can be used to draw ninja sword. I thought about triangle/rectangle draw in each point returned by action.move. But swipe may not be always as straight line. Users swipe finger on the screen in random direction. So triangles/rectangles have to be rotated to certain angle to draw a smooth sword. I just can't determine how to calculate the desired angle.

Can you guys help me out to calculate the rotation angle?

Is triangle stripe helpful? if so then how can I draw triangle stripe in the scene?
andgamer
 
Posts: 6
Joined: Thu Oct 20, 2011 6:28 am

Re: How to create ninja sword in Andengine

Postby skyuzo » Fri Oct 21, 2011 2:16 am

andgamer wrote:Can you guys help me out to calculate the rotation angle?


You can do positionChange = currentPosition - lastPosition. positionChange will then give you the angle at which the swipe should be.

andgamer wrote:Is triangle stripe helpful? if so then how can I draw triangle stripe in the scene?


You don't necessarily need to use a triangle strip.

However--if you're sure you want to use a triangle strip, you'll want to understand what OpenGL is and what a triangle strip is first.
skyuzo
 
Posts: 76
Joined: Thu Sep 08, 2011 2:29 am

Re: How to create ninja sword in Andengine

Postby andgamer » Fri Oct 21, 2011 11:59 am

Thanks skyuzo

I will try by angle calculation. I will post the solution if could find any or ask for the help if face any problem.
andgamer
 
Posts: 6
Joined: Thu Oct 20, 2011 6:28 am

Re: How to create ninja sword in Andengine

Postby drjava72 » Thu Nov 10, 2011 1:55 pm

andgamer wrote:Thanks skyuzo

I will try by angle calculation. I will post the solution if could find any or ask for the help if face any problem.

so what was your solution to find angel???
Best Regards,
drJava72
drjava72
 
Posts: 287
Joined: Fri Apr 29, 2011 8:03 am

Re: How to create ninja sword in Andengine

Postby badchoice » Thu Nov 10, 2011 2:43 pm

I finally solved it all, I have the skeletal system ready, now I'm optimizing it, using pools for objects and transforms that are created a lot of times every frame

To get the angle, the solution was this

1. Create my own sprite with an origin, this origin will be this way

Syntax: [ Download ] [ Hide ]
  1. mysprite.setCenterRotation(origin.x, origin.y) 


and
@override
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setPosition(float x, float y){
  2.    super.setPosition(x - origin.x, y-origin.y);
  3. }
  4.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Whe you have this sprite, for each sprite you have to calculate its rotation, and the rotation is the parent rotation plus its rotation, finally you need to get the new position after the rotation, so first, add the local pos with the parent pos, and then add the rotation pos (using the simple 2d rotation matrix)

Its all on the code, I'll post it here when I have it all completely optimized and easy to use, anyway if anybody wants to help I can share the code I think it can be a good angendine extension :D
badchoice
 
Posts: 91
Joined: Wed Apr 06, 2011 9:23 am
Location: Barcelona

Re: How to create ninja sword in Andengine

Postby drjava72 » Mon Nov 14, 2011 9:25 am

badchoice wrote:I finally solved it all, I have the skeletal system ready, now I'm optimizing it, using pools for objects and transforms that are created a lot of times every frame

To get the angle, the solution was this

1. Create my own sprite with an origin, this origin will be this way

Syntax: [ Download ] [ Hide ]
  1. mysprite.setCenterRotation(origin.x, origin.y) 


and
@override
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setPosition(float x, float y){
  2.    super.setPosition(x - origin.x, y-origin.y);
  3. }
  4.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Whe you have this sprite, for each sprite you have to calculate its rotation, and the rotation is the parent rotation plus its rotation, finally you need to get the new position after the rotation, so first, add the local pos with the parent pos, and then add the rotation pos (using the simple 2d rotation matrix)

Its all on the code, I'll post it here when I have it all completely optimized and easy to use, anyway if anybody wants to help I can share the code I think it can be a good angendine extension :D


Nice effort. If you have some free minutes then please upload your code to some online repository.
Best Regards,
drJava72
drjava72
 
Posts: 287
Joined: Fri Apr 29, 2011 8:03 am

Next

Return to GLES1

Who is online

Users browsing this forum: No registered users and 15 guests