I am new to this forum, started working as an animator: Don't know anything about cocos, so my question is, can we make composition in cocos 2d, like how we change blend modes and all in Photoshop ? Also is it possible to generate effects such as glow in cocos 2d ?
Please sort out my doubts guys. Thank you :)
Sure you can..
e.g:
sprite.blendMode = [CCBlendMode blendModeWithOptions: #{
CCBlendFuncSrcColor: #(GL_SRC_ALPHA),
CCBlendFuncDstColor: #(GL_ONE_MINUS_SRC_ALPHA),
}];
for effects check CCEffect class, you can add blur, brightness, contrast and many more
Related
I needed to make an object in my game transparent, but it wasn't working properly. So, after some research, I later found out how to properly do alpha blending in Direct3D9 and implemented some code to make the object finally transparent. However, while I have a basic idea of it, I am still a bit confused on how it all works. I have done lots of research, but I have only found very vague answers which just left me more confused. So, what do these two lines of code really mean and do?
d3ddev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
d3ddev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
Alpha blending in D3D is done according to this equation
Color = TexelColor x SourceBlend + CurrentPixelColor x DestBlend
The setting you quote sets the "SourceBlend" to the alpha value of the source texture. The value of DestBlend is set to one minus the alpha value of the source texture. This is a classic post-blending setting. This kind of mode is used to "anti-alias" an image, for example to blur the edges of a circle so that they do not look pixelated. It is quite good for things like smoke effects or for semi-transparent objects like plastics.
Why do have to specify it? Well if you set the DestBlend to always be one, you get a kind of "ghosting" effect, like when you partially see a reflection in a pane of glass. This effect is particularly good when used with an environment map. Pre-blending can also be useful, but requires you change the format of your inputs.
I was wondering if there is a tool that will allow me to construct/trace a closed bezier curve based on a background image?
Basically I have a background image that represents some 2d curve which could be of some weird shape like a race track and I want to place some items along this path.
I figured that if I can derive a quadratic bezier curve that will overlap the image I would be able to use the mathematical equations for this curve to compute individual points along its path..
Does anyone know if such tool exists? Is my approach reasonable or totally off and there is a much simpler solution?
Thank you in advance.
I suggest building it yourself. It shouldn't be too difficult to build a level creator where you add your own background image, place your bezier key points along where they need to be and export the points into a plist. It'll even give you room for extending it and customizing it for your game.
Also, if you're planning on tracing a path along a road for a racing game, consider constructing the background from smaller road/tree/grass sprites. This way you can give them specific properties (such as canDriveOn, canHit and so on) and based on customized behaviour defined for each one of them, your 'driveable' path would be derived implicitly.
Skewing x and y coordinates doesn't give that kind of effect. Any ideas on how to achieve this kind of effect? I already use cccamera but there are no examples on how to properly implement this. This image btw is from cocos2dx tried the c++ code still didn't work
I feel I need to share this once and for all. So this is how camera works when you want a slanting ,45degree or pseudo3d view of your background :
First set your director to 3d perspective
[director_ setProjection:kCCDirectorProjection3D];
If you only want some of the sprites to appear this way then remember this
all nodes have camera (cocos2d v.3 doesn't seem to have it anymore I don't know why)
so you do this:
[mysprite.camera setEyeX:0 eyeY:-40 eyeZ:10];
[mysprite.camera setUpX:0 upY:0 upZ:1];
Play with the values that fits your need. Hope it will help others!
I am trying to figure out how to get the vertices of my cube after it has been rotates with glRotate3f()
Im using a sphere bounding box to narrow dow the possible collisions but I need to know the exact vertices to get an accurate collision. Can anyone help me figure this out. Thanks.
Perhaps not the answer you're looking for, but you're approaching your problem from the wrong angle. OpenGL should be used to draw your scene and only that. Scene management and anything that goes along with it (transformations, deformations...to name just a few) should be handled by you (or an appropriate framework).
See the pic:
I know gradients, but in this pic, the gradient border is irregular, just like pouring water.
I think you're referring to a "gradient" -- there is a LinearGradientBrush class that you can use for this purpose; you can also find an example on MSDN: Creating a Linear Gradient.