How to Stroke a line in Cocos2d? Is it possible to convert the stroke into sprite?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can draw lines by overriding the “draw” method, which would in turn result in the “stroke” effect you appear to be after. The question is a bit lacking in detail, so I’ll try to make the best of it.
Let’s say you want to draw a simple line on the screen, you could do the following:
With this class, you’d be able to call:
Which would then draw a line from the bottom left of the screen to the top right of the screen.
You would not convert this into a “sprite”, as it would be unnecessary to do so – but you could then treat this as if it were any other graphic in your game, as it is now it’s own subclass of CCNode … containing all the goodness that comes with that (positioning, etc).