Skip to content
Browse files

Add empty HUD layer

  • Loading branch information...
1 parent fb23f53 commit bcba9d853ff093210b8b29184fcfb3ccf802cd4e @clawoo committed Sep 21, 2011
Showing with 29 additions and 8 deletions.
  1. +7 −8 Classes/GameScene.cpp
  2. +9 −0 Classes/HudLayer.cpp
  3. +7 −0 Classes/HudLayer.h
  4. +6 −0 Pong.xcodeproj/project.pbxproj
View
15 Classes/GameScene.cpp
@@ -99,14 +99,6 @@ void GameScene::draw()
void GameScene::update(cocos2d::ccTime dt)
{
- // bounce off the walls, account for the 1px line around the game area
- if (CC_SPRITE_LEFT(ball_) + velocity_.x <= gameArea_.origin.x + 1
- || CC_SPRITE_RIGHT(ball_) + velocity_.x >= gameArea_.origin.x + gameArea_.size.width - 1)
- {
- velocity_.x = -velocity_.x;
- }
-
- // temporary
if (CC_SPRITE_BOTTOM(ball_) <= gameArea_.origin.y + 1)
{
CCLog("Player Lost");
@@ -116,6 +108,13 @@ void GameScene::update(cocos2d::ccTime dt)
{
CCLog("CPU Lost");
}
+
+ // bounce off the walls, account for the 1px line around the game area
+ if (CC_SPRITE_LEFT(ball_) + velocity_.x <= gameArea_.origin.x + 1
+ || CC_SPRITE_RIGHT(ball_) + velocity_.x >= gameArea_.origin.x + gameArea_.size.width - 1)
+ {
+ velocity_.x = -velocity_.x;
+ }
// the rect of the future position of the ball
CCRect futureRect = CCRectMake(CC_SPRITE_LEFT(ball_) + velocity_.x,
View
9 Classes/HudLayer.cpp
@@ -0,0 +1,9 @@
+//
+// HudLayer.cpp
+// Pong
+//
+// Created by Clawoo on 9/21/11.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
+
+#include "HudLayer.h"
View
7 Classes/HudLayer.h
@@ -0,0 +1,7 @@
+//
+// HudLayer.h
+// Pong
+//
+// Created by Clawoo on 9/21/11.
+// Copyright 2011 __MyCompanyName__. All rights reserved.
+//
View
6 Pong.xcodeproj/project.pbxproj
@@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
3BD1DEF614268A14001FD208 /* square.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BD1DEF514268A14001FD208 /* square.png */; };
3BD1DEF914268A23001FD208 /* GameScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3BD1DEF714268A23001FD208 /* GameScene.cpp */; };
+ 3BF0687A142A627B001F4025 /* HudLayer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3BF06878142A627B001F4025 /* HudLayer.cpp */; };
505574581045D68500A31725 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 506EDBA4102F4C9F00A389B3 /* AVFoundation.framework */; };
505574591045D68500A31725 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */; };
5055745A1045D68500A31725 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */; };
@@ -307,6 +308,8 @@
3BD1DEF514268A14001FD208 /* square.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = square.png; sourceTree = "<group>"; };
3BD1DEF714268A23001FD208 /* GameScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GameScene.cpp; sourceTree = "<group>"; };
3BD1DEF814268A23001FD208 /* GameScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameScene.h; sourceTree = "<group>"; };
+ 3BF06878142A627B001F4025 /* HudLayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HudLayer.cpp; sourceTree = "<group>"; };
+ 3BF06879142A627B001F4025 /* HudLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HudLayer.h; sourceTree = "<group>"; };
506EDB87102F4C4000A389B3 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
506EDBA4102F4C9F00A389B3 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
506EE05E10304ED200A389B3 /* libcocos2d libraries.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcocos2d libraries.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -684,6 +687,8 @@
BF83631C13286EF300F3C033 /* HelloWorldScene.h */,
3BD1DEF714268A23001FD208 /* GameScene.cpp */,
3BD1DEF814268A23001FD208 /* GameScene.h */,
+ 3BF06878142A627B001F4025 /* HudLayer.cpp */,
+ 3BF06879142A627B001F4025 /* HudLayer.h */,
);
path = Classes;
sourceTree = "<group>";
@@ -1429,6 +1434,7 @@
D4D9411313EADBA700555460 /* AppDelegate.cpp in Sources */,
D4C3D25213F25E5600192C16 /* RootViewController.mm in Sources */,
3BD1DEF914268A23001FD208 /* GameScene.cpp in Sources */,
+ 3BF0687A142A627B001F4025 /* HudLayer.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

0 comments on commit bcba9d8

Please sign in to comment.
Something went wrong with that request. Please try again.