cocos2d sgx error (background gpu access not permitted)

August 24th, 2010 GTekna No comments

If you have “background gpu access not permitted” error with iOS4 SDK, it is because cocos2d is still running at a very low frame rate. So you have to stop all the actions before going to a background mode.

- (void) applicationDidEnterBackground:(UIApplication *)application {
[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector] pause];
}

- (void)applicationWillResignActive:(UIApplication *)application {
[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector] pause];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
// call this to make sure you don’t start a second display link!
[[CCDirector sharedDirector] stopAnimation];
[[CCDirector sharedDirector] resume];
[[CCDirector sharedDirector] startAnimation];
}

Read more details here:

http://www.cocos2d-iphone.org/forum/topic/7326

Track the same UITouch Object

May 15th, 2010 GTekna 2 comments

You can track the same UITouch object by comparing each UITouch object’s hash.

NSUInteger touchHash = [touch hash]; // UITouch *touch

Categories: Development, Tips Tags: , ,

cocos2d Joystick

May 15th, 2010 GTekna 3 comments

Developed a simple joystick using cocos2d.  Feel free to use for your game project.

The current project only use a pad and cap images. You could add a stick!

Sorry the comment in source code is Korean. ^^;;

new line

[DOWNLOAD: TheFirstGood_JoyStick XCode Project File]

new line

Convert CGPoint/CGRect/CGSize to NSValue and vice versa

May 5th, 2010 GTekna No comments
1. Convert CGPoint/CGRect/CGSize to NSValue

NSValue *valPoint = [NSValue valueWithCGPoint:CGPointMake(10, 10)];

NSValue *valRect = [NSValue valueWithCGRect:CGRectMake(0, 0, 10, 10)];

NSValue *valSize = [NSValue valueWithCGSize:CGSizeMake(10, 10)];

new line

2. Get CGPoint/CGRect/CGSize out of NSValue

CGPoint pt = [valPoint CGPointValue];

CGRect rect = [valRect CGRectValue];

CGSize size = [valSize CGSizeValue];

Upgrade Current Target for iPad… Grayed Out

April 16th, 2010 GTekna No comments

You have to select a target first. After selecting a target, the menu will be enabled.

It’s simple, but I spent some time to figure it out. -_-;;

Categories: Development, Tips Tags: ,

ScreenFlow 2.0 10% discount coupon

April 1st, 2010 GTekna No comments

I found this web site that generates a coupon when you enter your email address.

https://widgetlaboratory.wufoo.com/confirm/special-10-discount-on-screenflow-20/#public

GTekna is sponsoring iPadDevCamp

March 29th, 2010 GTekna No comments

We are attending the iPadDevCamp as a sposor!

The iPadDevCamp (iPhoneDevCamp) will be held at the eBay campus in San Jose from Apr 16th through 18th.

Please, check the iPhone/iPad application promotion services we offer here.

Categories: News Tags: , , , , ,

What is passed with ccTouchBegan event

January 11th, 2010 labor No comments

- (BOOL) ccTouchesBegan:(NSMutableSet *)touches withEvent:(UIEvent *)event
- (BOOL) ccTouchesMoved:(NSMutableSet *)touches withEvent:(UIEvent *)event
- (BOOL) ccTouchesEnded:(NSMutableSet *)touches withEvent:(UIEvent *)event
- (BOOL) ccTouchesCancelled:(NSMutableSet *)touches withEvent:(UIEvent *)event

; This is call-back function that means “called by system(or cocos2d)”

(NSMutableSet *)touches – (UITouch touch = [touches anyObject];)
; This mutable set includes information of touches newly began.

(UIEvent *)event – (UITouch touch = [[event allTouches] anyObject];)
; This UIEvent class includes information for all touches (check the manual for detail)

To read a location where touch event has been triggered (using cocos2d)

CGPoint pt = [touch locationInView:[touch view]];
CGPoint location = [[Director sharedDirector] convertToGL:pt];

For instance, when you touch first one and keep it and touch second.

ccTouchesBegan will be triggered twice and first parameter will have one touch for each time and second parameter will have one at first touch and two at second touch. It means first parameter contains information for only touch newly began and second parameter has info for all touches.

Tips for detection of two moving touches >>>>

When ccTouchesMoved is triggered, there is no way to determine this moved touch comes from where.
Let’s say there are two touches(A, B) and one(A) moved to another location, we don’t know this touch was A or B.

BUT, when touch moves slowly, I can tell which one moves actually.
First of all, I had to save each location of two touches and when “touch move” event is triggered, check the distance between new moved location with each location of two saved touches.

I used this function to calculate the distance between two points(CGPoint)
static inline int
ptdiff(const CGPoint a, const CGPoint b)
{
return sqrt((a.x – b.x) * (a.x – b.x) + (a.y – b.y) * (a.y – b.y));
}

So, I just assume that nearer point is previous location.
Fact) The distance of two touches will be at least 20 because of finger size (Depending on finger size, it might be different)
With this fact, just find the point within 20.
Categories: Development, Tips, cocos2d Tags:

How to redeem an iTunes store promotion code?

January 9th, 2010 GTekna No comments

You get a promotion code for iTunes store. Now what?

You need to redeem it to download the item.

1. Open (launch)  iTunes.

2. Click “iTunes Store” on the left panel.

3. Cliek on “Redeem” link at the bottom.

It’s that easy, but I didn’t know what to do when I got a promotion code. :)



And I found this great article explaining how to redeem the code with iPhone:

http://www.innerfence.com/howto/redeem-free-promo-code-for-iphone-app-from-iphone-or-itunes



Touch events on the hidden statusbar

January 9th, 2010 GTekna No comments

I spent a lot of time figuring out why a touch event is not passed to an UIButton located at (0, 0) whose size is 20 x 20 on the Simulator. 

I created an UIButton programmatically and added an event hander by using

addTarget:self  action: @selector(buttonTouchUpInsideHandler:) forControlEvents:UIControlEventTouchUpInside

 Of course I added

- (void) buttonTouchUpInsideHandler: (id)sender

I set a break point inside “buttonTouchUpInsideHandler” mehtod, but it was never hit.

So I implemented “touchedEnded” for the button’s parent UIView. While clicking (touching) the parent UIView, I happened to find that any touch event whose y-position is lower than 20 is not passed to the parent view’s “touchesEnded” method.  I immediately realized that that’s the height of the hidden status bar.

I tested the same code on my iPhone, but it was working perfectly. The button got a touch event and its touch handler was called.

It seems that it is a bug in the Simulator.  So in case you encounter the same problem, don’t waste you time!!

I also found this article:
https://devforums.apple.com/message/132010#132010