I'm having a spot of trouble trying to get this to work
I basically have a CCParticleSystem (created in Sprite Builder) that I want to follow a sprite but I want the emitter node to leave a trail of sorts... kind of like an airplane leaves a trail of exhaust fumes behind it
As far as I can make out there are no setting in Sprite Builder that I can change to allow this so I went looking for a solution in code
I found this in the documentation:
self.myParticleNode.particlePositionType = CCParticleSystemPositionType.Free
Which declares that the particles will be positioned relative to the Physics World and not be affected by the position of the emitter, but it appears to not do a thing
Any help or suggestions on this would be greatly appreciated
I found that CCParticleSystems particle positioning doesn't actually function when the Emitter Node is scaled in any way... this has posed a problem for me because I wanted a zoomed out camera effect.
Never mind.
Looks like this just won't work for now
Related
I am trying to make a Retro Tenis Game in Unity2D but I have some issues with the colliding system.
My controller does not collide with the walls. It goes through them.
It should stop in the wall like pic1 but it goes through it like pic2.
Can anyone help me, please?
pic1
pic2
UPDATE#1: I added a RigidBody component but it does not fix it. (pic3)
pic3
You shouldn't use the colliding system for this purpose. It would be much better that the script in charge of moving your paddle was able to control its maximum and minimum height too (note that the screen size can change, and the paddles should move at different heights depending on the screen size).
Although if you want to do it with the collision system and "walls" that limit the space of the paddles, both the "walls" and the paddles need to have a correctly positioned BoxCollider2D and the paddles an extra kinematic Rigidbody2D too (as they can move).
Also make sure to move the paddles using physics and not modifying its position with transform.position (see Rigidbody2D.MovePosition)
Edit: Unity2D physics system is rather a complicated topic and difficult to get it well on your own. I'd suggest to learn the basics in the Unity Learning Platform. You could start with this project.
You need add RigidBody2D to your "circle"
I would like to try and make a game similar to Altos Adventure. I am having trouble starting.
How to set up the terrain so that my character doesnt get stuck?
I simply drew a test sprite for the ground in photoshop. What collider2d should I use?
I use polygon collider and reduce friction in the material. But the character gets stuck, hits small invisible bumbs and it feels awful. The worst part is connecting 2 ground sprites together! The point where they connect is always messy.
I have a question for the future as well. How would I add the endless part of the game?
Would having many "pieces" set up and just spawning them as the player rides down work?
I havent written any code yet as the problem is simply in the physics in my opinion.
Thanks to anyone who takes the time and tries to help!
To move your player use rigid body.AddForce(Vector3 direction, ForceMode forceMode); then create a Physics Material with friction = 0 and put it in your player's collider.
I'm beginning with Unity3D and I'm having a problem with the lightning.
I made a simple infinite scroller with a road going straight, and I want to add a pointlight in the middle of my screen, in order to have the road at this place enlightened, whereas the remaining is darker.
However, the light seems to follow the middle of my sprite when this one is moving, instead of remaining static.
Here is a gif of what I have:
My SpriteRenderer has the Sprite/Diffuse material and I added some postprocessing on the camera in order to have a bloom effect on the road.
Do you know what could be the problem here?
Thank you.
Pretty sure you have the Light GameObject as a child of the Sprite, so it follows the parent transform
Hello everyone I an very new to cocos2d, so I apologize if this is a simple question. I would like to create to sprites that collide when they hit each other.
For instance, one sprite, spriteA, is in a fixed position on the screen. And another sprite, spriteB, is moving around the screen. SpriteB will collide with spriteA. If that doesn't make sense or you don't understand it, tell me and I will elaborate further. Any help is appreciated. Thank YOU!
Try using Chipmunk or Box2d physics systems. These are included with Cocos2d and work by having a physics simulation that updates with every time the graphics change on screen.
The physics simulation will tell you if two objects are overlapping, and will provide physical attributes like weight, slipperiness (friction), speed and direction, which creates reactions like bouncing, sliding, realistic loss of speed and changes of direction on impact.
If you are new to physics simulation, here's a 30 second run down:
Create "bodies" in the physics simulation that represent each graphical sprite
Bodies are usually defined more simply than their graphical counterparts, like a circle, square or simple polygon shape
In order to update the graphics on the screen accurately, first you establish a pixels to meters ratio. Meters are notional (i.e. made up) measurement that is used in the physics sim
Each time the physics simulation "ticks", you update the graphics on screen accordingly
So if a body in the physics sim moves 1 meter, you might transform the pixel sprite 32 pixels
Here's a good tute on collision detection using Box2d.
http://www.raywenderlich.com/606/how-to-use-box2d-for-just-collision-detection-with-cocos2d-iphone
enjoy
Its actually very simple:
Just schedule a timer: [self schedule:#selector(checkForCollision:)];
Specify the method: - (void)checkForCollision:(ccTime)dt {}
In the curly braces, make CGRects for each sprite using CGRectMake.
Then in the same method, just call: if (CGRectIntersectsRect) {}
That easy!
Well technically speaking when the 2 sprites interact, or share at least one common point, then they are colliding. I'm a little confused by your question. Are you asking for direction on how to make the sprite move on screen, or are you asking how to handle the actual collision(such as calling a method if they collide)?
I made a game that using a character that can moving left or right by touching the screen, above the character, it is a apple, what i need is the apple will fall down, the character may push the apple up again just like playing volleyball.
That's the problem,what i have learnt from "bounding ball" is give a sprite a shape and body, then they would collide automatically,when i give shape and body to the character, the animation is not work, the character moved and after a second he "jumps" to the starting point,whatever i using setPosition or Action(MoveTo) to sprite are also useless
moving the body is not work too.I use touchmoved to set the body->p,it keeps shaking and when i release the button, it "fly" alway out of bound..........
Can anyone tell me what should i do or give a similar example(e.g. volleyball and something like that),Plx help!!!
I appreciate that if anyone can give me a hand.
Adding a chipmunk body and shape to a sprite is not the best way to go about this. Try not to think from the screen's point of view! Instead, create a controller that contains a reference to the physics body and the sprite.
Using a physics engine, such as chipmunk, can be a bit daunting. It helps to enable debug drawing. Have a look into how you can best do that! There is some code you can take from the cocos2d chipmunk example, that comes with the normal cocos2d download)
I take it you've added a "ground" shape as a static shape and have gravity set?
When you move a body with body->p = cpv(x,y); the problem is that you don't change the objects state other than it's position. To the physics engine, it's like you teleport the object. If the object was falling, it will still be falling.
So now, your falling object is not touching the ground. Its speed increases. You "teleport" it again.. but until it bumps into anything, gravity will keep increasing its falling speed.
So, if you move an object to another point, be sure to reset all forces and the velocity on that object, if this need to be done!
A better way than using body->p is to use these functions:
void cpBodySlew(cpBody *body, cpVect pos, cpFloat dt)
void cpBodyUpdateVelocity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt)
void cpBodyUpdatePosition(cpBody *body, cpFloat dt)
The documentation of these functions isn't too ridged, but there's other documentation out there. Give it a google :-p I haven't fully mastered using these functions yet either (I'm still trying to get around Chipmunk too) but they're the way to go about it.
Alternatively you can (instead of setting body->p) set the velocity of the object directly (though cpBodySlew does this for you)
The latest chipmunk code is doing this with a pivot joint in between the object to be grabbed and the mouse (touch): ChipmunkDemo.c.
See also: Mouse interaction