Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Tools & Utilities

Reply
 
LinkBack Thread Tools Display Modes
Old 06-10-2011, 03:12 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 1
isacart20 is on a distinguished road
Exclamation Help with moving an object?

I am looking just to do something simple.

I want to say have a square and when you touch an ipod screen the square moves up and when you release the square falls down.

Any help would be muchly appreciated.

I havent tried anything yet.
isacart20 is offline   Reply With Quote
Old 06-12-2011, 09:40 AM   #2 (permalink)
Registered Member
 
Join Date: May 2011
Location: Warsaw
Posts: 21
ios dev is on a distinguished road
Default

Quote:
Originally Posted by isacart20 View Post
I am looking just to do something simple.

I want to say have a square and when you touch an ipod screen the square moves up and when you release the square falls down.

Any help would be muchly appreciated.

I havent tried anything yet.
You can try to create UIImageView object add it to your view and animate it on touch events

Code:
UIImageView *im = [[UIImageView alloc] initWithFrame:CGRectMake(210, 250, 100, 100)];

Code:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{
// here run animation
  		[UIView beginAnimations:nil context:nil];
		[UIView setAnimationCurve: UIViewAnimationCurveEaseIn];
		[UIView setAnimationDuration:5];
		
		[im setCenter:CGPointMake(im.center.x,im.center.y-400)];
		[UIView commitAnimations];
}


- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{
// here run reverse animation - just a sample (you can manipulate variables)
}
__________________
------------------
JellyBugs game iPhone
------------------
Android outsourcing |iPhone outsourcing |
ios dev is offline   Reply With Quote
Old 06-12-2011, 11:16 AM   #3 (permalink)
Registered Member
 
Join Date: Jun 2011
Posts: 3
lastw0nd3r is on a distinguished road
Default

or you can have square as a set of images and pass it to array?

Quote:
NSArray *animationArray=[NSArray arrayWithObjects:
[UIImage imageNamed:@"SquareImage1.jpg"],
[UIImage imageNamed:@"SquareImage2.jpg"],
[UIImage imageNamed:@"SquareImage3.jpg"],
[UIImage imageNamed:@"SquareImage4.jpg"],
nil];

And then perform animation on it..

UIImageView *animationView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0,320, 460)];
animationView.backgroundColor=[UIColor redColor];
animationView.animationImages=animationArray;
animationView.animationDuration=3;

//you can always change this count if you want
animationView.animationRepeatCount=0;
[animationView startAnimating];
[self.view addSubview:animationView];
[animationView release];
Hope it helps..
Cheers
Lucky
lastw0nd3r is offline   Reply With Quote
Reply

Bookmarks

Tags
fall down, gravity, moving ccsprite, tutorial, up move

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 417
11 members and 406 guests
AppleDev, chemistry, Emy, Gi-lo, ipodphone, mistergreen2011, pipposanta, QuantumDoja, Retouchable, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,129
Posts: 402,924
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0