Search Results

Search found 560 results on 23 pages for 'cocos2d x'.

Page 10/23 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Singleton method not getting called in Cocos2d

    - by jini
    I am calling a Singleton method that does not get called when I try doing this. I get no errors or anything, just that I am unable to see the CCLOG message. Under what reasons would a compiler not give you error and not allow you to call a method? [[GameManager sharedGameManager] openSiteWithLinkType:kLinkTypeDeveloperSite]; The method is defined as follows: -(void)openSiteWithLinkType:(LinkTypes)linkTypeToOpen { CCLOG(@"WE ARE IN openSiteWithLinkType"); //I NEVER SEE THIS MESSAGE NSURL *urlToOpen = nil; if (linkTypeToOpen == kLinkTypeDeveloperSite) { urlToOpen = [NSURL URLWithString:@"http://somesite.com"]; } if (![[UIApplication sharedApplication]openURL:urlToOpen]) { CCLOG(@"%@%@",@"Failed to open url:",[urlToOpen description]); [self runSceneWithID:kMainMenuScene]; } } HERE IS THE CODE TO MY SINGLETON: #import "GameManager.h" #import "MainMenuScene.h" @implementation GameManager static GameManager* _sharedGameManager = nil; @synthesize isMusicON; @synthesize isSoundEffectsON; @synthesize hasPlayerDied; +(GameManager*) sharedGameManager { @synchronized([GameManager class]) { if (!_sharedGameManager) { [[self alloc] init]; return _sharedGameManager; } return nil; } } +(id)alloc { @synchronized ([GameManager class]) { NSAssert(_sharedGameManager == nil,@"Attempted to allocate a second instance of the Game Manager singleton"); _sharedGameManager = [super alloc]; return _sharedGameManager; } return nil; } -(id)init { self = [super init]; if (self != nil) { //Game Manager initialized CCLOG(@"Game Manager Singleton, init"); isMusicON = YES; isSoundEffectsON = YES; hasPlayerDied = NO; currentScene = kNoSceneUninitialized; } return self; } -(void) runSceneWithID:(SceneTypes)sceneID { SceneTypes oldScene = currentScene; currentScene = sceneID; id sceneToRun = nil; switch (sceneID) { case kMainMenuScene: sceneToRun = [MainMenuScene node]; break; default: CCLOG(@"Unknown Scene ID, cannot switch scenes"); return; break; } if (sceneToRun == nil) { //Revert back, since no new scene was found currentScene = oldScene; return; } //Menu Scenes have a value of < 100 if (sceneID < 100) { if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) { CGSize screenSize = [CCDirector sharedDirector].winSizeInPixels; if (screenSize.width == 960.0f) { //iPhone 4 retina [sceneToRun setScaleX:0.9375f]; [sceneToRun setScaleY:0.8333f]; CCLOG(@"GM: Scaling for iPhone 4 (retina)"); } else { [sceneToRun setScaleX:0.4688f]; [sceneToRun setScaleY:0.4166f]; CCLOG(@"GM: Scaling for iPhone 3G or older (non-retina)"); } } } if ([[CCDirector sharedDirector] runningScene] == nil) { [[CCDirector sharedDirector] runWithScene:sceneToRun]; } else { [[CCDirector sharedDirector] replaceScene:sceneToRun]; } } -(void)openSiteWithLinkType:(LinkTypes)linkTypeToOpen { CCLOG(@"WE ARE IN openSiteWithLinkType"); NSURL *urlToOpen = nil; if (linkTypeToOpen == kLinkTypeDeveloperSite) { urlToOpen = [NSURL URLWithString:@"http://somesite.com"]; } if (![[UIApplication sharedApplication]openURL:urlToOpen]) { CCLOG(@"%@%@",@"Failed to open url:",[urlToOpen description]); [self runSceneWithID:kMainMenuScene]; } } -(void) test { CCLOG(@"this is test"); } @end

    Read the article

  • inconsistent setTexture behavior in cocos2d on iPhone after using CCAnimate/CCAnimation

    - by chillid
    Hi, I have a character that goes through multiple states. The state changes are reflected by means of a sprite image (texture) change. The state change is triggered by a user tapping on the sprite. This works consistently and quite well. I then added an animation during State0. Now, when the user taps - setTexture gets executed to change the texture to reflect State1, however some of the times (unpredictable) it does not change the texture. The code flows as below: // 1. // Create the animation sequence CGRect frame1Rect = CGRectMake(0,32,32,32); CGRect frame2Rect = CGRectMake(32,32,32,32); CCTexture2D* texWithAnimation = [[CCTextureCache sharedTextureCache] addImage:@"Frames0_1_thinkNthickoutline32x32.png"]; id anim = [[[CCAnimation alloc] initWithName:@"Sports" delay:1/25.0] autorelease]; [anim addFrame:[CCSpriteFrame frameWithTexture:texWithAnimation rect:frame1Rect offset:ccp(0,0)]]; [anim addFrame:[CCSpriteFrame frameWithTexture:texWithAnimation rect:frame2Rect offset:ccp(0,0)]]; // Make the animation sequence repeat forever id myAction = [CCAnimate actionWithAnimation: anim restoreOriginalFrame:NO]; // 2. // Run the animation: sports = [[CCRepeatForever alloc] init]; [sports initWithAction:myAction]; [self.sprite runAction:sports]; // 3. stop action on state change and change texture: NSLog(@"Stopping action"); [sprite stopAction:sports]; NSLog(@"Changing texture for kCJSports"); [self setTexture: [[CCTextureCache sharedTextureCache] addImage:@"SportsOpen.png"]]; [self setTextureRect:CGRectMake(0,0,32,64)]; NSLog(@"Changed texture for kCJSports"); Note that all the NSLog lines get logged - and the texture RECT changes - but the image/texture changes only some of the times - fails for around 10-30% of times. Locking/threading/timing issue somewhere? My app (game) is single threaded and I only use the addImage and not the Async version. Any help much appreciated.

    Read the article

  • ccfollow actions in cocos2d

    - by Srinivas
    ccfollow actions is following my projectile correctly. when, double tap recognised. see the below code. were am mistaken. here is my code:- - (void)update:(ccTime)dt { if (numTaps==1 ) { [self runAction:[CCFollow actionWithTarget:nextProjectile worldBoundary:CGRectMake(0,0,1050,350)]]; } } - (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { numTaps = [[touches anyObject] tapCount]; printf("Tapcount : %d",numTaps); if (numTaps ==1) { nextProjectile = [[CCSprite spriteWithFile:@"Weapon.png"] retain]; nextProjectile.position = ccp(nextprojectile .contentSize.width/2+65, nextprojectile.contentSize.height/2+70); [nextProjectile runAction:[CCSequence actions: [here's my nextprojectile actions],nil]]; } } after seen the above code. a question raised by you. why am mentioning the ccfollow action in if condition. answer is here, ordinarily, am mention in update function it will not works, when i set this if condition it works after double tap recognised. how to rectify this issue? any help would be highly appreciated.

    Read the article

  • how to close layer that showed in other layer in cocos2d-iphone

    - by yegomo
    I have one layer called alayer, and there is a button called abutton, when click the button, another layer called blayer will show in alayer, not replaceScene, please look at the following code, alayer.m -(void)abuttonclicked:(id)sender { blayer *blayer = [blayer node]; blayer.position = ccp(1,1); [self addChild:blayer]; } blayer.m has a button called bbutton and string value called bstring, I want to click the b button, it will close blayer (remove blayer from alayer), and pass the string value bstring to alayer, please look at following code, -(void)bbuttonclicked:(id)sender { // how can do here to close its self(remove its self from alayer), and pass the bstring to alayer? } thanks. ps. I can use NSUserDefault to pass the string value, but I think it's a bad way to do this, is there another way to pass value?

    Read the article

  • bounding a sprite in cocos2d

    - by Srinivas
    am making a canon to fire objects. back of the canon the plunger is attached. plunger acts for set speed and angle. canon rotates 0-90 degree and plunger moves front and back for adjust speed. when am rotates the canon by touches moved its working fine. when plunger is pull back by touches moved and it rotates means the plunger is bounds outside of the canon. how to control this:- my code for plunger and canon rotation on touches moved. ( para3 is the canon , para6 is my plunger):- CGPoint touchLocation = [self convertTouchToNodeSpace:touch]; CGPoint oldTouchLocation = [touch previousLocationInView:touch.view]; oldTouchLocation = [[CCDirector sharedDirector] convertToGL:oldTouchLocation]; oldTouchLocation = [self convertToNodeSpace:oldTouchLocation]; if (CGRectContainsPoint(CGRectMake(para6.position.x-para6.contentSize.width/2, para6.position.y-para6.contentSize.height/2, para6.contentSize.width, para6.contentSize.height), touchLocation) && (touchLocation.y-oldTouchLocation.y == 0)) { CGPoint diff = ccpSub(touchLocation, oldTouchLocation); CGPoint currentpos = [para6 position]; NSLog(@"%d",currentpos); CGPoint destination = ccpAdd(currentpos, diff); if (destination.x < 90 && destination.x >70) { [para6 setPosition:destination]; speed = (70 + (90-destination.x))*3.5 ; } } if(CGRectIntersectsRect((CGRectMake(para6.position.x-para6.contentSize.width/8, (para6.position.y+30)-para6.contentSize.height/10, para6.contentSize.width, para6.contentSize.height/10)),(CGRectMake(para3.position.x-para3.contentSize.width/2, para3.position.y-para3.contentSize.height/2, para3.contentSize.width, para3.contentSize.height)))) { [para3 runAction:[CCSequence actions: [CCRotateTo actionWithDuration:rotateDuration angle:rotateDiff], nil]]; CGFloat plungrot = (rotateDiff); CCRotateTo *rot = [CCRotateTo actionWithDuration:rotateDuration angle:plungrot]; [para6 runAction:rot]; } }

    Read the article

  • How to obtain cocos2d-x 3.1 templates into XCode 5.x?

    - by Mayerz
    I cloned Cocos2d-x repo from github, everything works fine but I can't find how to install the Cocos2d templates into XCode. I saw that people were used to use this file, located at the root of the repo: ./install-templates-xcode.sh -f -u but it looks like this script file has been removed, any help appreciated. edit: Still no answer to this problem, even the slightest clues could help me. Are there still templates for XCode? Couldn't get answers from #cocos2d-x irc

    Read the article

  • bounding a sprite in cocos2d

    - by Srinivas
    am making a canon to fire objects. back of the canon the plunger is attached. plunger acts for set speed and angle. canon rotates 0-90 degree and plunger moves front and back for adjust speed. when am rotates the canon by touches moved its working fine. when plunger is pull back by touches moved and it rotates means the plunger is bounds outside of the canon. how to control this:- my code for plunger and canon rotation on touches moved. ( para3 is the canon , para6 is my plunger):- CGPoint touchLocation = [self convertTouchToNodeSpace:touch]; CGPoint oldTouchLocation = [touch previousLocationInView:touch.view]; oldTouchLocation = [[CCDirector sharedDirector] convertToGL:oldTouchLocation]; oldTouchLocation = [self convertToNodeSpace:oldTouchLocation]; if (CGRectContainsPoint(CGRectMake(para6.position.x-para6.contentSize.width/2, para6.position.y-para6.contentSize.height/2, para6.contentSize.width, para6.contentSize.height), touchLocation) && (touchLocation.y-oldTouchLocation.y == 0)) { CGPoint diff = ccpSub(touchLocation, oldTouchLocation); CGPoint currentpos = [para6 position]; NSLog(@"%d",currentpos); CGPoint destination = ccpAdd(currentpos, diff); if (destination.x < 90 && destination.x >70) { [para6 setPosition:destination]; speed = (70 + (90-destination.x))*3.5 ; } } if(CGRectIntersectsRect((CGRectMake(para6.position.x-para6.contentSize.width/8, (para6.position.y+30)-para6.contentSize.height/10, para6.contentSize.width, para6.contentSize.height/10)),(CGRectMake(para3.position.x-para3.contentSize.width/2, para3.position.y-para3.contentSize.height/2, para3.contentSize.width, para3.contentSize.height)))) { [para3 runAction:[CCSequence actions: [CCRotateTo actionWithDuration:rotateDuration angle:rotateDiff], nil]]; CGFloat plungrot = (rotateDiff); CCRotateTo *rot = [CCRotateTo actionWithDuration:rotateDuration angle:plungrot]; [para6 runAction:rot]; } }

    Read the article

  • Targeting all subclassed CCSprites (cocos2d)

    - by Joethemonkey101
    I'm working on a method to end the level, but to do so, I have to see that all of the enemy character have been killed. If my enemies are CCSprites, how do I make a method that detects if all of them are dead? I'm tracking their health with an int called enemyHp. For example, this is an if statement I made to remove the enemy if (enemy.enemyHp <= 0) { To recap - I want to make a method that detects when all enemies have been killed. Thanks

    Read the article

  • CCLabelAtlas setString doesn't update label

    - by JonnyFunFun
    Hello! I have a CCLabelAtlas that I have on a layer to display the current score within my game...the problem that I am having with it is that it does not update when I use [scoreLabel setString:]. Here's how I have it laid out: In the header: @interface GameScene : CCLayer { ... CCLabelAtlas* scoreLabel; } And in the init: scoreLabel = [[CCLabelAtlas alloc] initWithString:@"0" charMapFile:@"scoreCharMap.png" itemWidth:6 itemHeight:8 startCharMap:'.']; [scoreLabel setPosition:ccp(105, 414)]; [self addChild:scoreLabel z: 6]; scoreCharMap.png is a custom map that includes ./0123456789 of my desired font. When the score is changed, I attempt to do this to get the label to update with the current score: NSString* str = [[NSString alloc] initWithFormat:@"%d", [[GameRunner sharedInstance] currentScore]]; [scoreLabel setString: str]; [str release]; [scoreLabel draw]; Problem is that it doesn't ever update - it just sits there and displays 0. I know for a fact due to breakpoints and debugging that setString is being called, and that the string that it should be displaying is correct - but it just doesn't update. Hard-coding the value and saying [scoreLabel setString:@"1234"] does nothing, either. What am I doing wrong here? I am using Cocos2d 0.99 - thanks in advance!

    Read the article

  • How to set the position of a sprite within a box2d body?

    - by Frank
    Basically I have 2 polygons for my body. When I add a sprite for userData, the position of the texture isn't where I want it to be. What I want to do is adjust the position of the texture within the body. Here's the code sample of where I am setting this: CCSpriteSheet *sheet = (CCSpriteSheet*) [self getChildByTag:kTagSpriteSheet]; CCSprite *pigeonSprite = [CCSprite spriteWithSpriteSheet:sheet rect:CGRectMake(0,0,40,32)]; [sheet addChild:pigeonSprite z:0 tag:kPigeonSprite]; pigeonSprite.position = ccp( p.x, p.y); bodyDef.position.Set(p.x/PTM_RATIO, p.y/PTM_RATIO); bodyDef.userData = sprite; b2Body *body = world->CreateBody(&bodyDef); b2CircleShape dynamicCircle; dynamicCircle.m_radius = .25f; dynamicCircle.m_p.Set(0.0f, 1.0f); // Define the dynamic body fixture. b2FixtureDef circleDef; circleDef.shape = &dynamicCircle; circleDef.density = 1.0f; circleDef.friction = 0.3f; body->CreateFixture(&circleDef); b2Vec2 vertices[3]; vertices[0].Set(-0.5f, 0.0f); vertices[1].Set(0.5f, 0.0f); vertices[2].Set(0.0f, 1.0f); b2PolygonShape triangle; triangle.Set(vertices, 3); b2FixtureDef triangleDef1; triangleDef1.shape = &triangle; triangleDef1.density = 1.0f; triangleDef1.friction = 0.3f; body->CreateFixture(&triangleDef1);

    Read the article

  • How to delay my AI move

    - by Mythili
    I am doing a game like chess. As soon my player move is completed(if he starts move from one place to another), my AI move is started (before my player reaching his destination ). Sometimes i find difficult which AI coin is moved now. how to delay it.

    Read the article

  • How can I add sprite image from a set of sprites which have different properties for each sprite?

    - by srikanth rongali
    In my application one player and 10 targets are there. Each target appears one after the other (from target1 to target10). It's a shooting game. If we hit the first target then second target will come. The targets have properties like name, speedOfGunDraw, probability to hit the player, speedOfFire. What should I do to make them appear one after the other with these properties. I am using CCMenuItem for the target. I am using a sprite for the player. Please give me idea to do this. Thank You.

    Read the article

  • How to recognize the touch of a non regular sprite image ?

    - by srikanth rongali
    I have a sprite and if it is touched the touch should be recognized. I used the coordinates to do so. I took the coordinates (min x, min y, max x , max y)of the sprite image. But The sprite image is not a rectangular shape. So, even if I touch the coordinates outside the sprite and inside the rectangular bounds the sprite is recognized. But for my application I need only the sprite to be recognized. So, I have to take only the coordinates of the sprite, but it is not regular shape. I am using CCSprite in my program. So, what can I do to for only the sprite to be selected ? Which classes should use for this? Thank You.

    Read the article

  • How can I a sprite image from a set of sprites which have different properties for each sprite?

    - by srikanth rongali
    In my application one player and 10 targets are there. Each target appears one after the other (from target1 to target10). It's a shooting game. If we hit the first target then second target will come. The targets have properties like name, speedOfGunDraw, probability to hit the player, speedOfFire. What should I do to make them appear one after the other with these properties. I am using CCMenuItem for the target. I am using a sprite for the player. Please give me idea to do this. Thank You.

    Read the article

  • How to solve the delay problem in animation of sprites ?

    - by srikanth rongali
    My problem is, I did coding for a sprite. It should change it should change it's image from( 1, 2, 3). It should look like count down time to start a game. 1, 2, 3 are 3 png images. But the images are not displayed in equal intervals of time. I mean time between (1 - 2), (2 - 3) is not same. It is random. Please help me with my problem. Help me if there is better solution than what I am doing.(My animation should be like, before any game starts we see count down 1 then 2 then 3 then GO). -(id)init { if((self = [super init])) { [[CCDirector sharedDirector] setAnimationInterval:60.0/60]; [[CCDirector sharedDirector] setDisplayFPS:NO]; CCAnimation* numberAnimation = [CCAnimation animationWithName:@"countDown" delay: 60.0/60]; for( int i=1;i<4;i++) [numberAnimation addFrameWithFilename: [NSString stringWithFormat:@"number_%02d.png", i]]; id numberAction = [CCAnimate actionWithAnimation: numberAnimation restoreOriginalFrame:NO]; id action2 = [CCFadeOut actionWithDuration:0.5f]; CCSprite *number; number = [CCSprite spriteWithFile:@"number.png"]; .... } }

    Read the article

  • Image stretching

    - by NIL
    Hi All, I want Stretch a image. For that i use sprite. I want stretch sprite & this stretching is may be Circular or curve animation. I don't understand what methode used for that. Can anyone help me?

    Read the article

  • Writing the code iby dividing it into more files.

    - by srikanth rongali
    My problem is, I need a background image, a sprite(with animation) on left edge, another sprite(with animation) at other edge, a number count animation 1-2-3 at middle. I got all these when I wrote all in same file.(like [self addChild:label], [self addChild:sprite].., But in this it needs touch enables for both sprites separately, and touchDisabled to the remaining screen. So thought of writing in different files. But now it is not working. I kept one sprite, background image, numbercount in one file and another spritr in other file. Either I am getting the second sprite or the (sprite+background+numberCount) is displayed. This is my problem. plz give me solution. Thank You

    Read the article

  • Writing the code by dividing it into more files in cocoatouch.

    - by srikanth rongali
    My problem is, I need a background image, a sprite(with animation) on left edge, another sprite(with animation) at other edge, a number count animation 1-2-3 at middle. I got all these when I wrote all in same file.(like [self addChild:label], [self addChild:sprite].., But in this it needs touch enables for both sprites separately, and touchDisabled to the remaining screen. So thought of writing in different files. But now it is not working. I kept one sprite, background image, numbercount in one file and another spritr in other file. Either I am getting the second sprite or the (sprite+background+numberCount) is displayed. This is my problem. plz give me solution. Thank You

    Read the article

  • Restrict sprite movement to vertical and horizontal

    - by Daniel Granger
    I have been battling with this for some time and my noob brain can't quite work it out. I have a standard tile map and currently use the following code to move my enemy sprite around the map -(void) movePlayer:(ccTime)deltaTime { if (CGPointEqualToPoint(self.position, requestedPosition)) return; float step = kPlayerSpeed * deltaTime; float dist = ccpDistance(self.position, requestedPosition); CGPoint vectorBetweenAB = ccpSub(self.position, requestedPosition); if (dist <= step) { self.position = requestedPosition; [self popPosition]; } else { CGPoint normVectorBetweenAB = ccpNormalize(vectorBetweenAB); CGPoint movementVectorForThisFrame = ccpMult(normVectorBetweenAB, step); if (abs(vectorBetweenAB.x) > abs(vectorBetweenAB.y)) { if (vectorBetweenAB.x > 0) { [self runAnimation:walkLeft]; } else { [self runAnimation:walkRight]; } } else { if (vectorBetweenAB.y > 0) { [self runAnimation:walkDown]; } else { [self runAnimation:walkUp]; } } if (self.position.x > movementVectorForThisFrame.x) { movementVectorForThisFrame.x = -movementVectorForThisFrame.x; } if (self.position.y > movementVectorForThisFrame.y) { movementVectorForThisFrame.y = -movementVectorForThisFrame.y; } self.position = ccpAdd(self.position, movementVectorForThisFrame); } } movePlayer: is called by the classes updateWithDeltaTime: method. the ivar requestedPosition is set in the updateWithDeltaTime method as well, it basically gets the next point out of a queue to move to. These points can be anywhere on the map, so if they are in a diagonal direction from the enemy the enemy sprite will move directly to that point. But how do I change the above code to restrict the movement to vertical and horizontal movement only so that the enemies movement 'staircases' its way along a diagonal path, taking the manhattan distance (I think its called). As shown by my crude drawing below... S being the start point F being the finish and the numbers being each intermediate point along its path to create a staircase type diagonal movement. Finally I intend to be able to toggle this behaviour on and off, so that I can choose whether or not I want the enemy to move free around the map or be restricted to this horizontal / vertical movement only. | | | | | | | | | | | | | | | | | | | | | |F| | | | | | | | | |5|4| | | | | | | | | |3|2| | | | | | | | | |1|S| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |

    Read the article

  • How would one use Cocos2d to create a game like this.

    - by John Stewart
    http://itunes.apple.com/us/app/angry-birds/id343200656?mt=8&ign-mpt=uo%3D6 So I am getting started with this all game dev thing on iphone and I decided that I will start playing with Cocos2d as my starting engine. Now just so i have a goal in mind, I picked angry birds as my initial target of what sort of game play would I like to learn to build. This is not going to be a market release game. This is totally going to be learning purposes only. So to start off my question is: Would something like this be achievable using Cocos2d? How would I go about building the physics for this? How can one do a screen scroll like the way they do in cocos2d? (any example code would be great) This is just to start off. If you have any particular questions please do add to this question.

    Read the article

  • How do you install cocos2d-iphone on the Mac?

    - by johnfromberkeley
    There are no good instructions for installing cocos2d for iPhone on the mac. I downloaded the current build from git, a folder called "cocos2d-iphone-0.99.1". i put this folder in /Developer/Libary. Q: is this right? I tried running the file called "install_template.sh". it said the templates were already installed. Instead, I manually dragged the templates folders where they belong, and they ~do~ appear in the XCode's "New Project" dialog. When I create a new cocos2d project, I see all these red links for project files, instead of the regular black links. When I try to open them in the finder, nothing happens. I can tell that something is not linked. Can someone please help walk me through this? Thanks!

    Read the article

  • Seperation of drawing and logic in games

    - by BFree
    I'm a developer that's just now starting to mess around with game development. I'm a .Net guy, so I've messed with XNA and am now playing around with Cocos2d for the iPhone. My question really is more general though. Let's say I'm building a simple Pong game. I'd have a Ball class and a Paddle class. Coming from the business world development, my first instinct is to not have any drawing or input handling code in either of these classes. //pseudo code class Ball { Vector2D position; Vector2D velocity; Color color; void Move(){} } Nothing in the ball class handles input, or deals with drawing. I'd then have another class, my Game class, or my Scene.m (in Cocos2D) which would new up the Ball, and during the game loop, it would manipulate the ball as needed. The thing is though, in many tutorials for both XNA and Cocos2D, I see a pattern like this: //pseudo code class Ball : SomeUpdatableComponent { Vector2D position; Vector2D velocity; Color color; void Update(){} void Draw(){} void HandleInput(){} } My question is, is this right? Is this the pattern that people use in game development? It somehow goes against everything I'm used to, to have my Ball class do everything. Furthermore, in this second example, where my Ball knows how to move around, how would I handle collision detection with the Paddle? Would the Ball need to have knowledge of the Paddle? In my first example, the Game class would have references to both the Ball and the Paddle, and then ship both of those off to some CollisionDetection manager or something, but how do I deal with the complexity of various components, if each individual component does everything themselves? (I hope I'm making sense.....)

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >