Jump to content
  • Advertisement
oblivion_

cocos2dx drawing polygons and move them

Recommended Posts

Say i want to draw 5 triangles and to move them in different directions over time. how would one achieve this in cocos2d-x?

Share this post


Link to post
Share on other sites
Advertisement

Someone might be able to give you an example, but it seems like your best bet might be to work through some Cocos2d-x tutorials.

I found this:

https://www.raywenderlich.com/1848-cocos2d-x-tutorial-for-beginners

It's 'archived', and doesn't have a date on it, so it's possible it's out of date with respect to the current version of the library. But I'd guess it's mostly still applicable (and maybe entirely so). It looks like it covers basic motion, in which case it should answer your specific question, generally speaking.

There's also the main site here:

http://www.cocos2d-x.org/

I don't know much about Cocos Creator, but it might allow for doing what you have in mind via higher-level tools. The site also has a 'Learn' section (in the menu at the top), which includes documentation and a 'Get Started' section with tutorials.

I see some indications that Cocos2d-x has some shape-drawing functionality. I don't know much about this, but you might be able to use it for what you describe. Failing that, you can of course use images/sprites.

[Edit: Minor clarification.]

Edited by Zakwayda

Share this post


Link to post
Share on other sites

After posting the above, it occurred to me that this might be homework. If it is, I'd state that in your post, and also check the site rules, as I think there are some rules/guidelines about posting homework questions.

Share this post


Link to post
Share on other sites
17 minutes ago, Zakwayda said:

After posting the above, it occurred to me that this might be homework. If it is, I'd state that in your post, and also check the site rules, as I think there are some rules/guidelines about posting homework questions.

no it is not homework, there is no straightforward way to do what i am asking (maybe there is one that i have overlooked) , that's why i am asking

Share this post


Link to post
Share on other sites
3 hours ago, oblivion_ said:

no it is not homework, there is no straightforward way to do what i am asking (maybe there is one that i have overlooked) , that's why i am asking

Without looking through the library itself... The standard approach once the sprites are drawn is to use a random variable that decides the direction of movement per sprite, and you can cycle this per (x) ticks, or with a timer.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!