I am a beginner on cocos2d an I'm looking for a way to stack 3 sprites one above another in cocos2d. I guess it would require collision detection but I could figure out a way to make it work. Does anybody has any idea that could help me out?
This is a rather vague question without any code examples, but you can simply adjust the position parameters of your CCSprite objects so they are stacked on top of each other. If you used the dimensions of each sprite in your position formula, you can have it automatically know where each sprite is located and position the next one right above it.
Related
So I've been making my own shooter in C++ using SFML library. I couldn't find a proper answer to a problem I've encountered. Is there any function in SFML that would set player and enemies sprites not to the size of their textures (just rectangles), but to the "colored" areas of the source png file so the sprite would match the shape of player?
So from what I understand you probably want to create a sprite with the same bounds as your texture assuming your player is "colored" and the rest in you texture is transparent. First, your texture and the sprite (sf::Sprite) will have the same bounds as the image (png) and the scale you set, depending on the image size. However, the only thing that will be drawn onto the screen will be your "colored" part since the rest of the image has 0 as the alpha value (transparent). So there is no actual need to create a sprite which has the same "bounds" as it's visible parts. Unless, you are handling collisions.
If you are indeed handling collisions, please look into something called pixel perfect collision detection. (SFML "intersect" function uses Bounding Box detection, if you're using that.)
If this is not an answer you seek, please elaborate the question and I'll help out :)
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!
Hi I am Using Cocos2d with Box2d.
I have a "Stick.png" as CCSprite Now I want to bend it from center downwards and Upwards from the end and start of image.. I am trying to make game like hill Climb that is using only one Green image of a grass strip for the whole vehicle Path/Road used in the game.
I shall be thankful.
Please Help
You can use the skewX skewY properties to achieve this effect. There are also CCSkewBy and CCSkewTo actions to animate skewing.
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).
Hi
I am making a cocos2d game, In that i am adding enemies dynamically at different position, and animating them using action.
Enemies are appearing in screen according to the order I added. But I want to show sprites according to its Y value.
Please tell me is there any api in cocos2d to do sorting the sprites according to sprite position, or which is the best way to accomplish this.
Thanks,
Best way to update zOrder based on Y position
Z Order Operations - "Perspective" based games
CCSpriteBatchNode / reorder Z