I'm currently discovering Cocos2D in combination with SpriteBuilder and I'm making stuff bounce around.
It's quite fun :)
What I'm trying to figure out is the following :
- On SpriteBuilder, I create a CCSprite, and I enable physics for this one.
- I can invoke it in XCode, and do whatever I want with it. Plus, the sprite is reacting accordingly to the physics settings applied to it. Great.
Now, what I would like to do is to disable the physics from this sprite in the code. I don't find a method in the Cocos2D API that would do the trick.
Can you help me out ?
Thank you for your time and help ;)
I write the correct answer then:
sprite.physicsBody.sensor = TRUE;
Related
I'm trying to add some velocity to an object in Xcode's scene editor. I looked in the Objects Library and saw "Velocity Field" which creates what it calls SKVelocityFieldNode. There's no documentation at all on SKVelocityFieldNode? Google can't find anything. Anyone know whether this can be used to apply a velocity to an SKNode?
It’s what you get when you create a velocity field.
https://developer.apple.com/documentation/spritekit/skfieldnode/1519778-velocityfield
I am making a game in Swift. I have used both UIKit and SpriteKit, but never in the same app. I was wondering how to leverage the power of both of them (They are going to be a lot of menus). If you knew a tutorial I could use, or could tell me, I would be very appreciative. I also would like to know if there is a shortcut for this in xcode (e.g. storyboards)
I would highly recommend you to stick with SpriteKit and to create menus etc with SKNodes. I know that it is really seductive to use UIKit in a game for buttons etc. but you've got many possibilities right in SpriteKit which replaces UIKit-elements.
For example you can use an SKLabelNode instead of an UILabel. Also you've got many more possibilities in SpriteKit to make your menu 'smooth' (For example with SKTransition or SKAction).
Also an example for a menubutton would be:
//Button
var playButton = SKSpriteNode(imageNamed: "yourImage.png")
playButton.position = CGPointMake(300, 300)
playButton.name = "playButton"
addChild(playButton)
Then in your touchesBegan method you can handle that button touch.
Also one very important point to only use SpriteKit is, that you can port a iOS game to OSX within a few hours.
how can we Add Parallax Scrolling in Cocos 2D version 3 (IOS) . I have explored many tutorials but nothing has helped me. i have tried following code but its not working . can you please list down steps to achieve Parallax Scrolling in Cocos2D game. i ma newbie in game Development . your help will be highly appreciated. Thanks
CCParallaxNode *voidNode = [CCParallaxNode node];
[voidNode addChild:bg4 z:1 parallaxRatio:ccp(3.5f, 3.5f) positionOffset:ccp(3.5f, 3.5f)];
[voidNode addChild:_spacedust1 z:2 parallaxRatio:ccp(3.5f, 3.5f) positionOffset:ccp(3.5, 3.5)];
[self addChild:voidNode];
You just move the voidNode. All children that you add to voidNode will be moved relative to voidNode.
So for example the foreground should be moved exactly like the voidNode then you make a parallaxRatio of ccp(1.f, 1.f).
Then the background for example should be moved slower than the foreground you make a parallaxRatio of ccp(0.6f, 0.6f).
I'm having a bit of trouble with Corona's transitions with easing.
Here is my code:
transitionTime = 120
transition.to( newDot, { time = transitionTime, y = newDot.destination_y, transition=easing.outBounce } )
Unfortunately, it's not actually bouncing at all. It just seems to be moving normally. I'm not sure if I'm doing something wrong or if something else needs to be done before the easing transition will display.
Any help would be greatly appreciated!
Thank you!
I'm pretty sure that transition API never worked properly. What I always would do is make 2 transitions with one having a slight delay like so:
transition.to(newDot, {time=80,y = newDot.destination_y - 50})
transition.to(newDot, {delay=80, time=40, y=newDot.destination_y})
Just work with something like that so just change up the numbers to your liking. Hope this helps.
I think you are using old corona version.The easing properties inBounce, outBounce, inOutBounce, outInBounce are applied only in new versions of corona. These properties will not work in old one.
I've recently started checking out XNA. All is going well and I've even got a working sample started. One thing that's been bugging me is that whenever I place my mouse over the game window it disappears. I don't know if this is the default behavior but I would like to change this so that I can see my mouse. Any and all advice is appreciated.
Simply set IsMouseVisible to true in your main game class(preferably in your Initialize method or Game class constructor) :
IsMouseVisible = true;