I am new in iphone and as well in cocos2d
I have some queries about a game i am working on it.
Actually i have a background with some trees and bushes.and i have an object which keeps on moving and my background of trees and bushes is static at the back. I want the application to repeat the background and it give me a look that my object is moving forward.
Can anybody Guide me please.
I also want to implement speed so also guide me that how can i change the speed of background repetition. so that it gives a look that my object is slow or fast
Thanks
waiting for your positive response.
Regards
sHaH
Work through this excellent tutorial:
http://www.raywenderlich.com/3857/how-to-create-dynamic-textures-with-ccrendertexture
It'll surely help you.
The section "Repeating Backgrounds" explains how to make a texture repeat and animate it.
In order to change the speed you can make PIXELS_PER_SECOND a dynamic variable.
Related
I want to make an endless vertical scrolling layer that gives the impression that the main character is moving upwards. I have been brainstorming on how to achieve this.
My issue is that I want objects to appear as if they are coming from above and below the screen at the same time. Secondly, I want to be able to move the main character to create and destroy box2d joints between it and some of the objects appearing on the screen. What is the best way to achieve this with consuming too much memory? I would appreciate any help on this.
Apple did a wonderful tutorial of this in a WWDC 2011 video session. It was "UITableView Changes, Tips & Tricks" and it's about 35m40sec into the video.
Since the use of the UITableView is really just a UIScrollView for the purposes of the background, you could just use a UIScrollView and you can either have it move on timer or events as needed.
Think of your player as moving within a stationary bounding box. The background can scroll using the aforementioned pooling method (as the background tile scrolls off the screen it is placed into a pool, and before a new tile is instantiated the pool is checked for available reusable tiles). Thirdly, your enemy objects will simply approach from either the bottom of the screen or the top.
Imagine your idea without the scrolling background (flying effect) and you should find that the problem is relatively straightforward.
I also needed and endless scrolling background layer. This can do exactly that, and it is super simple to set up and use. Just copy the four files in to the cocos2d folder in your project, then follow the quick tutorial seen on the github. Make sure the image you use is seamless (when you line them up vertically you can't tell where one ends.
I am currently working on an app, which includes a paint function. It actually doesn't work that bad, but the problem is, that the refresh-rate or the frequency of the calls for the touchesMoved-method is too bad.
If you move the fingers fast over the screen, the lines get many edges and it doesn't look that good. So i thought about increasing the call-frequency for this method. Would that be a good and even possible solution for my problem?
Maybe you can help me with my problem. Thank you in advance.
Think about this approach: Look at Adobe's Ideas App on the AppStore. If touchesEnd, work with NSBezierPath to get a smoother look without edges. You basically store the points in touchesMoved in an array? So you got the points to insert in the Bezier Path functions. You have a edgy look while drawing but after releasing it looks kind of smooth. I did so in one of my projects and result is fairly okay.
(But there are many other approaches to build a drawing application.)
Demo App from Apple: Click here
What is the best way I center the screen to follow the character? Should I use CCCamera or just move the background around?
I am new to cocos2d so please show me exact code.
BTW: I am also using box2d in this project.
Thanks
Try this...
[self runAction:[CCFollow actionWithTarget:(your hero) worldBoundary:CGRectMake(0,0,1050,350)]];
It will follow your character (your hero).
Hey there,
You have always to choose between the best way and the best way in your situation. A problem has multiple ways how you can solve it. So I can just tell you how I did it.
A few weeks ago I released my first game. (If you are interested check it out: Birdy!) I also used Cocos2d and had the same problem like you. The player should always be in the center of the screen. I've choosen the way to move the background. I added 2 things to the GameScene: The background and the bird. And I set the background as the bird's delegate. So as soon as the bird performs a jump for example, the background is moved in the opposite direction.
I think for my situation it was the best method. But I can't talk about CCCamera because I never did anything with that class...
I hope I could help you a little bit. But it's always a bit difficult to find the right way. So you should also think about things you will optionally add in the future. So perhaps my way does not fit your requirements...
I hope also my english is understandable...
Sandro Meier
i am trying to make a Kaleidoscope app in iPhone.
Some one can tell me how can make it, what kind of techs i must use, please !
thanks a lot for your helps, i am so worried now !
Thanks
To generate a random background and then do the two mirror reflections, you will need CoreGraphics/Quartz, and know about layers, and CGContexts. In order to vary the background based on the movement of the iPhone, you need to learn how to read the accelerometer.
This is if you want to make it look similar to a real Kaleidoscope. Otherwise you could take the much simpler approach of creating a graphic formulaicly based on random data that is then cropped to a pie slice and repeated twice to create a simple Kaleidoscope graphic.
What is the easiest and most practical way to implement smooth frame-based animation on the iPhone? I know that image sequences are easy to do, but if I have say 30 images flashing per second (30 fps) for 5 seconds, will it freeze up? Are there massive memory implications with this method?
I'm designing a game that will be mostly static, but there will be animations for some of the user actions. I'm hoping that OpenGL (etc.) won't be necessary.
I'd recommend looking at the Cocos2d-iPhone open source game engine.
Using an AtlasSprite it should be relatively straight forward to achieve the result you want.
This question needs to be more clear. Are you trying to display a sprite based animation? Or animate an image along a path? Or both?
If you have a series of images to animate, using UIImageView's animationImage is an easy way to go about it, although it is probably not efficient enough for a full scale game.