Is there a sprite kit way to do the Cocos2d draw method?
-(void)draw
{
ccDrawColor4B(255, 255, 255, 255);
ccDrawCircle(mySprite.position, attackRange, 360, 30, false);
[super draw];
}
Thank you!
There's no custom OpenGL drawing in Sprite Kit (as of iOS 7.1).
While you can draw circles and other shapes using SKShapeNode, they are meant primarily for debugging purposes (analog to the ccDraw functions in cocos2d). The main problem being that shape nodes are not drawn in batches (inefficiently), unlike sprites.
Related
There is SKShapeNode but it can't be used in conjunction with masks.
Is there an equivalent to UIView's -drawRect: or CALayer's -renderInContext: in Sprite Kit? I looked at SKSpriteNode. Don't see a way to perform custom drawing with Core Graphics functions.
How would you do it?
Nope. There's no custom drawing in Sprite Kit in the likes of custom OpenGL or Core Graphics.
You can create textures using Core Graphics methods and filter textures with CIFilter though, in case that helps.
In my app i required a line with some texture in it. I draw a simple line with..
ccDrawLine( ccp(0, 0), ccp(s.width, s.height) );
But I required to add texture in it.
Thanks,
Here is tutorial by Ray Wenderlich which teaches how to add textures using opengl.
I'm trying to draw several particles as we touch and moving. When user tilts the device, particles moves to the tilted side.
I made this steps by using each particles on each Image View. But it's too slow when making like 100 image views.
SoilView= [[UIImageView alloc] initWithFrame:CGRectMake(currentPoint.x + randomDist1, CurrentPoint.y + randomDist2, 30, 30)];
[SoilView setImage:SoilImage];
so I tried to change this to particle animation, but it was not working well. most particle animation sample was just blowing up or scatters everywhere. so I couldn't find a way to make my code.
Is there any ways to make each particles to work like each views?
How can I solve this problem? Could Someone please help me?
I would use OpenGL for particle animations. To get you started take a look at this particle Generator and the OpenGL ES Blog posts of the project's author http://iphonedevelopment.blogspot.com/2009/05/opengl-es-from-ground-up-table-of.html
I am trying to do a highlighting action on the iPhone. I can draw lines an such with the finger but now I want to be able to highlight over that. Any algorithms out there you can point me to that does that? Using OpenGL ES off course.
Thanks
This should produce a pink highlight around your geometry:
render_model();
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glColor3f(1.0f, 0.0f, 1.0f);
glLineWidth(2);
glCullFace(GL_FRONT);
render_model_using_GL_LINES();
glCullFace(GL_BACK);
glEnable(GL_TEXTURE_2D);
I would like to draw 2d shapes like this in an iPhone app:
alt text http://www.shaggyfrog.com/junk/beveled-circle.jpg
I asked a similar question here to see if I could do it easily with Quartz, but didn't get a solution. So I got to thinking that I might be able to leverage an exsiting 2d library out there, and then I thought of cocos2d.
The goal is to draw these kinds of beveled shapes dynamically, i.e., using arbitrary colours, and possibly with the highlight/bevel drawn at an arbitrary position.
Is this possible with cocos2d?
As far as my knowledge of cocos2d goes, cocos2d will not enable you to do this in any other way than OpenGL would allow you to do. Cocos2d uses OpenGL under the hood. Cocos2d comes with no built-in set for creating such graphics.
Since the bevel is used to create a 3D effect, perhaps you shouldn't be looking at simulating it with 2D drawing, but instead use a 3D drawing library? OpenGL would certainly be capable of drawing such shapes. Cocos2d focuses on 2D drawing instead of 3D.
I'm not sure if Cocos2D would allow for a custom object to draw 3D using the underlying OpenGL mechanism. I have never tried.
Wouldn't it instead be easier to create the image in photoshop and adjust colors dynamicly? I'm not sure what you are trying to do.
You could also create a mask shape with a transparent "bevel effect" and scale that along with the image you need to have shine?
Aside from the bevel effect, if you want to "colorize" each semi-circle, you can use [sprite setColor:] or sprite.color = ccc3(r,g,b)
CCSprite *sprite = [CCSprite spriteWithSpriteSheet:sheet rect:CGRectMake(32 * idx,0,128,32)];
[sprite setColor:ccc3(CCRANDOM_0_1()*255,CCRANDOM_0_1()*255,CCRANDOM_0_1()*255)];
You would design a "white semicircle" with beveled (gray) edges. Then you can make sprites and color each separately.