iphone - Loading and Unloading background images as game moves -


hey guys, have raidan style 2d flying/fighter game im working on. upon moving standard nsobject framework cocos2d, have encountered issue background image/sprite.

before cocos2d, background large vertically. 320x9999 (or something). loaded , created illusion large level. cocos2d has limitations on image sizes, forced slice image 33 different background images each @ 320x480.

understanding memory big deal on ios platform, decided create 2 background ccsprites: ccsprite *background1, *background2; background2 ontop of background1.

using these 2 backgrounds, jet moves screen, each background move inversely down screen @ equal rate, first background1 moves off screen vertically, released memory , new sprite loaded background1 , background1 positioned above background2 vertically.

as background2 moves off screen, released , new image loaded background2 , placed ontop of background1.

creating illusion of constant , consistent background.

q. seem valid method? q. how go achieving programatically? have physics of movement , ready go. im little unsure how cocos.

once again, in advance!

a1) yes it's valid way so, , it's easy thing ht ecode goes somthing (i may have programatical errors ,consider psudo code!):

if(background[1].position.y < 0) {     [layer removechild:background[1] cleanup:yes];     background[1] = background [2];     background[2] = [ccsprite spritewithfile:"file id"]     background[2].position = ccp(0,480);     [background[2] runaction:[ccmoveby actionwithduration:1 position:ccp(0,1)]] } 

a2) if needed guide gave implementation need , if mean don't know how implement plysics stuff using cocos2d-iphone try these manuals :

http://www.raywenderlich.com/457/intro-to-box2d-with-cocos2d-tutorial-bouncing-balls

http://www.raywenderlich.com/475/how-to-create-a-simple-breakout-game-with-box2d-and-cocos2d-tutorial-part-12

http://www.raywenderlich.com/505/how-to-create-a-simple-breakout-game-with-box2d-and-cocos2d-tutorial-part-22


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -