My game needs to implement night vision effect. I'm using a CCRenderTexture as a mask, and I plan to draw the visible areas onto the mask by using [rangeSprite visit];
However, it need GL_SUBTRUCT mode. I searched cocos2d's codes, but found nowhere the macro is used. Does it mean cocos2d do not support this?
Have you solved this? I have the same problem, and am approaching it currently by using a blendmode like this:
[light setBlendFunc:ccBlendFuncMake(GL_DST_ALPHA, GL_ZERO)];
...whereas light is a sprite I paint onto my CCRenderTexture, which gets laid over the screen.
Related
I'm wanting to create a WoW cooldown effect where a player does some action and is not able to do the action again until the sprite is fully shown again. I have a grayed out version of the same sprite and am wanting to slowly reveal the sprite until it is fully available again. So, there will be a slow blend vertically of the gray and colored sprite.
Is there a way to do this with built in functionality with Cocos2d and CCSprite?
I'm using v2 of Cocos2d so I could write a shader which I think would be pretty easy, but before I went this route I wanted to see if there is an easier way.
Take a look to the CCProgressTimer class. If I understand right, it will make what you want
You can use CCFadeIn to animate the colored sprite over the grayed sprite :
[coloredSprite runAction:[CCFadeIn actionWithDuration:1.0f];
Some times textures disappear from sprites. I have a sprite that appears with white color and it should have a texture on it and a label that should have a text in it an it appears with black color. The labels are subclasses of sprite so this problem is related to Sprites. Could some one tell me what is the problem ? Did some one meet this bug to in Cococs2D on Android ? Thank's !
I had such a problem when I was doing navigation from "outside" of cocos2d i.e. i relied on Android's native back button's callback to change scenes. Apparently this callback doesn't work on the same thread as cocos and causes this problem (maybe something with WeakReferences in the TextureCache). Hope it helps :)
Are you using pvr? When I tried using pvr I was getting what sounds like the same issues. I switched to png and it fixed the problem for me.
When using SFML 1.6, I have run into a small problem, that I know there is an easy solution, but I currently cannot think of it/ haven't been able to find the answer via research.
I know that I have to transform the sprite to a global position using TransformToGlobal(someVector), but I don't know where to put it.
Here is an example of my code that I am using which does not work because it isn't in the global position.
if(sprite.GetSubRect().Contains(mouseX, mouseY))
sprite.SetImage(someImage);
else
sprite.SetImage(someOtherImage);
I tried adding sprite.TransformToGlobal(sprite.GetPosition()); before it, but it did not work as well.
You could try using the transformed mouse position and then checking if the sprites contains the mouse:
sf::Vector2f mousePos = App.ConvertCoords(App.GetInput().GetMouseX(), App.GetInput().GetMouseY());
if(sprite.GetSubRect().Contains(mousePos.x, mousePos.y))
sprite.SetImage(someImage);
else
sprite.SetImage(someOtherImage);
I want to animate the way a CCSprite appear on screen.
At the moment I'm using "addChild" to display the sprite on screen but I want it to appear on screen with animation.
Is is possible?
Thanks
Try reading through the Cocos2D programming guide, there is a subject on animation with source code there. http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:index.
I read a topic on OpenGL.org where a guy made this:
http://coreytabaka.com/programming/cube-demo/
He said to release the source code but he never did,
does anyone how I could get the same idea?
Has to do with clearing the window with alpha but drawing
on it as well.. just don't get how to get OpenGL setup like
that. From there I can do my stuff but I'd like a base for
this running in C++ with VisualStudio,
Anybody has something like this laying around ? Or can show
pieces of the code to get this kind of rendering done.
Render the 3d scene to a pbuffer.
Use a color key to blend the pbuffer to screen.