so the first step is to draw an image on gimp, just a quick draw
then i export the drawing as beg1.png then i drag the drawing into my Xcode project
then after that, i put this line of code in my helloworld.m
under the import
CCSprite *begger1;
under the init
begger1 = [CCSprite spriteWithFile: @"beg1.png"];
begger1.position = ccp( 50, 100 );
[self addChild:begger1];
Okay, now the next step surely is to control my character to walk around right? So if i press on the right hand side i want to see my character walk to the right hand side and when i press on the left hand side i want to see my character walk to the left hand side
Under the init, i schedule myTimer function to run
[self schedule:@selector(myTimer:)];
My Timer function to move the character from left to right
begger1.position = ccp( begger1.position.x + 100*dt, begger1.position.y );
if (begger1.position.x > 480+32) {
begger1.position = ccp( -32, begger1.position.y );
}
Then Finally I need to click somewhere on the screen and I want my picture to go to the area i click, so
on top of the import
#import "CCTouchDispatcher.h"
on the Init
self.isTouchEnabled = YES;
-(void) registerWithTouchDispatcher
{
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
}
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
return YES;
}
- (void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint location = [self convertTouchToNodeSpace: touch];
clickornot=2;
[begger1 stopAllActions];
[begger1 runAction: [CCMoveTo actionWithDuration:1 position:location]];
}
Now when i click on any spot, my picture will fly to that area, freaking cool
Now what is the next step what is the next step
The iPhone 5 isn't flawless. The hardware is not really the problem, but a lack of OS improvements. The saying used to be Apple knew what we wanted before we did. The current truth is its customers are much more informed in regards to technology and the industry.coques iphone 4
ReplyDelete