Search Results

Search found 828 results on 34 pages for 'flip booth'.

Page 3/34 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How do you make a UIBarButtonItem animation flip?

    - by Andrew Arrow
    In the iPod app on the iPhone there is a UIBarButtonItem in the upper right toolbar that flips between the song and track listings for the album. When you select the button, the button itself does a flip animation. Is there a way to do this with: CGContextRef context = UIGraphicsGetCurrentContext(); [UIView beginAnimations:nil context:context]; [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:[self superview] cache:YES]; Do I need to make a UIBarButtonItem with initWithCustomView vs. initWithImage to achieve this?

    Read the article

  • How can I flip a UITableView?

    - by Sheehan Alam
    I am trying to flip a UITableViewController but I don't think I am doing it properly: LeaderBoardTableViewController* leaderBoardView = [[[LeaderBoardTableViewController alloc] initWithNibName:@"LeaderBoardTableViewController" bundle:nil]autorelease]; //[self.navigationController pushViewController:leaderBoardView animated:YES]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[self view] cache:YES]; [self.view addSubview:leaderBoardView]; [UIView commitAnimations]; I believe the culprit is in the line: [self.view addSubview:leaderBoardView]; But am not sure how to resolve.

    Read the article

  • TabBar as rootController flip animation.

    - by user558076
    Hi there, I'm using a TabBarController as the root controller for my app. I have all the views I use (5 tabs) all hooked together through it in interface builder. What I'm trying to do is trigger a slide or flip animation when moving between tabs. However, I only want this to occur when I change tabs programmatically (ie the animation is triggered when someone does a swipe gesture in the one of the views, but not when they just select one of the tabs). The way I'm currently handling this is by calling: [appDelegate.myTab setSelectedIndex:0]; when the iphone detects a swipe. I've been searching the internet for 5 straight hours and can't seem to find a way to add an animation here. It'd be really cool if there were something like: [appDelegate.myTab setSelectedIndex:0 animated:(YES)]; However, there isn't... I can't imagine no one's ever tried this before, but for the life of me, I can't find anything online that explains how this can be done. Thank you in advance for your help.

    Read the article

  • Having problem loading data from AppDelegate using UITableView into a flip view, loads first view bu

    - by Ms. Ryann
    AppDelegate: @implementation Ripe_ProduceGuideAppDelegate -(void)applicationDidFinishLaunching:(UIApplication *)application { Greens *apricot = [[Greens alloc] init]; apricot.produceName = @"Apricot"; apricot.produceSight = @"Deep orange or yellow orange in appearance, may have red tinge, no marks or bruises. "; apricot.produceTouch = @"Firm to touch and give to gentle pressure, plump."; apricot.produceSmell = @"Should be Fragrant"; apricot.produceHtoP = @"raw, salads, baked, sauces, glazes, desserts, poached, stuffing."; apricot.produceStore = @"Not ripe: place in brown paper bag, at room temperature and out of direct sunlight, close bag for 2 - 3 days. Last for a week. Warning: Only refrigerate ripe apricots."; apricot.produceBest = @"Spring & Summer"; apricot.producePic = [UIImage imageNamed:@"apricot.jpg"]; Greens *artichoke = [[Greens alloc] init]; artichoke.produceName = @"Artichoke"; artichoke.produceSight = @"Slightly glossy dark green color and sheen, tight petals that are not be too open, no marks, no brown petals or dried out look. Stem should not be dark brown or black."; artichoke.produceTouch = @"No soft spots"; artichoke.produceSmell = @" Should not smell"; artichoke.produceHtoP = @"steam, boil, grill, saute, soups"; artichoke.produceStore = @"Stand up in vase of cold water, keeps for 2 -3 days. Or, place in refrigerator loose without plastic bag. May be frozen, if cooked but not raw."; artichoke.produceBest = @"Spring"; artichoke.producePic = [UIImage imageNamed:@"artichoke.jpg"]; self.produce = [[NSMutableArray alloc] initWithObjects:apricot, artichoke, nil]; [apricot release]; [artichoke release]; FirstView: @implementation ProduceView -(id)initWithIndexPath: (NSIndexPath *)indexPath { if (self == [super init] ){ index = indexPath; } return self; } -(void)viewDidLoad { Ripe_ProduceGuideAppDelegate *delegate = (Ripe_ProduceGuideAppDelegate *) [[UIApplication sharedApplication] delegate]; Greens *thisProduce = [delegate.produce objectAtIndex:index.row]; self.title = thisProduce.produceName; sightView.text = thisProduce.produceSight; touchView.text = thisProduce.produceTouch; smellView.text = thisProduce.produceSmell; picView.image = thisProduce.producePic; } FlipView: @implementation FlipsideViewController @synthesize flipDelegate; -(id)initWithIndexPath: (NSIndexPath *)indexPath { if ( self == [super init]) { index = indexPath; } return self; } -(void)viewDidLoad { Ripe_ProduceGuideAppDelegate *delegate = (Ripe_ProduceGuideAppDelegate *) [[UIApplication sharedApplication] delegate]; Greens*thisProduce = [delegate.produce objectAtIndex:index.row]; self.title = thisProduce.produceName; bestView.text = thisProduce.produceBest; htopView.text = thisProduce.produceHtoP; storeView.text = thisProduce.produceStore; picView.image = thisProduce.producePic; } *the app works, the flip view for Artichoke shows the information for Apricot. Been working on it for two days. I have been working with iPhone apps for two months now and would very much appreciate any assistance with this problem. Thank you very much.

    Read the article

  • UIView to Form Sheet flip animation rotation issue

    - by GSD
    I have this view to form sheet flip animation that works great in portrait mode but not in any other orientations. In my code, I use it with a UIView embedded in another UIView, which is in the root view. The animation will be rotated. Anyone has an idea why? - (void)presentModalViewControllerWithFlipAnimation:(UIViewController *)modalViewController fromView:(UIView *)fromView { UIWindow* window = [[UIApplication sharedApplication] windows][0]; _fromViewSnapshot = [[UIImageView alloc] initWithFrame:fromView.bounds]; UIGraphicsBeginImageContext(fromView.bounds.size); [fromView.layer renderInContext:UIGraphicsGetCurrentContext()]; [_fromViewSnapshot setImage:UIGraphicsGetImageFromCurrentImageContext()]; [_fromViewSnapshot sizeToFit]; UIGraphicsEndImageContext(); _fromViewSnapshot.autoresizesSubviews = YES; _fromViewSnapshot.frame = [fromView.superview convertRect:fromView.frame toView:window]; [window addSubview:_fromViewSnapshot]; fromView.hidden = YES; modalViewController.modalPresentationStyle = UIModalPresentationFormSheet; [self presentViewController:modalViewController animated:NO completion:nil]; UIView __weak *presentedView = modalViewController.view.superview; UIGraphicsBeginImageContext(presentedView.bounds.size); [presentedView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage* modalSnapshot = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIView __weak *presentationSuperview = presentedView.superview; [presentedView removeFromSuperview]; UIImageView* presentationSnapshotView = [[UIImageView alloc] initWithImage:modalSnapshot]; presentationSnapshotView.autoresizingMask = UIViewAutoresizingNone; [_fromViewSnapshot.superview bringSubviewToFront:_fromViewSnapshot]; [UIView animateWithDuration:kFlipAnimationScaleSpeed delay:0 options:UIViewAnimationOptionCurveEaseIn|UIViewAnimationOptionBeginFromCurrentState animations: ^{ [UIView animateWithDuration:kFlipAnimationScaleSpeed delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations: ^{ _fromViewSnapshot.frame = [_fromViewSnapshot.superview convertRect:presentedView.frame fromView:presentationSuperview]; } completion:nil]; } completion:^(BOOL finished) { [UIView setAnimationBeginsFromCurrentState:YES]; [UIView transitionWithView:_fromViewSnapshot duration:kFlipAnimationSpeed options:UIViewAnimationOptionCurveEaseIn|UIViewAnimationOptionTransitionFlipFromRight animations: ^{ presentationSnapshotView.frame = _fromViewSnapshot.bounds; [_fromViewSnapshot addSubview:presentationSnapshotView]; } completion:^(BOOL finished) { [presentationSuperview addSubview:presentedView]; [presentationSnapshotView removeFromSuperview]; [_fromViewSnapshot removeFromSuperview]; }]; }]; } - (void)dismissViewControllerWithFlipAnimation:(UIView*)fromView completion:(void (^)(void))completion { UIWindow* window = [[UIApplication sharedApplication] windows][0]; UIView __weak *presentedView = self.presentedViewController.view.superview; UIGraphicsBeginImageContext(presentedView.bounds.size); [presentedView.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage* modalSnapshot = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [presentedView removeFromSuperview]; UIImageView* presentationSnapshotView = [[UIImageView alloc] initWithImage:modalSnapshot]; presentationSnapshotView.autoresizingMask = UIViewAutoresizingNone; presentationSnapshotView.frame = presentedView.frame; [window addSubview:presentationSnapshotView]; [UIView animateWithDuration:kFlipAnimationScaleSpeed delay:0 options:UIViewAnimationOptionCurveEaseIn|UIViewAnimationOptionBeginFromCurrentState animations: ^{ [UIView animateWithDuration:kFlipAnimationScaleSpeed delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations: ^{ presentationSnapshotView.frame = [fromView.superview convertRect:fromView.frame toView:window]; } completion:nil]; } completion:^(BOOL finished) { [UIView setAnimationBeginsFromCurrentState:YES]; [UIView transitionWithView:presentationSnapshotView duration:kFlipAnimationSpeed options:UIViewAnimationOptionCurveEaseIn|UIViewAnimationOptionTransitionFlipFromLeft animations: ^{ _fromViewSnapshot.frame = presentationSnapshotView.bounds; [presentationSnapshotView setImage:[(UIImageView*)_fromViewSnapshot image]]; [self dismissViewControllerAnimated:NO completion:nil]; } completion:^(BOOL finished) { [presentationSnapshotView removeFromSuperview]; _fromViewSnapshot = nil; completion(); }]; }]; }

    Read the article

  • Come visit us at OOW 2012 B2B Demo Booth!

    - by Nitesh Jain
    You’re invited to visit us at the Oracle B2B Demo POD at Oracle OpenWorld and JavaOne 2012. Please stop by at our booth to see cool demos on EDI X12, EDIFACT and SBRES (used in Airlines industry). We will also be showing integration with OSB, SOA Suite and BAM. Use this opportunity to see the product in action, learn, and get answers to your questions. We will be happy to meet you and hear about your B2B integration usecases and discuss our roadmap. The demo pod will be available at the Fusion Middleware Demo POD area on Monday, October 1 through Wednesday, October 3, 2012. Look forward to seeing you there! Happy OOW 2012! Ref: https://blogs.oracle.com/SOA/entry/come_visit_us_at_oow

    Read the article

  • Come visit us at OOW 2012 B2B Demo Booth!

    - by user701307
    You’re invited to visit us at the Oracle B2B Demo POD at Oracle OpenWorld and JavaOne 2012. OOW offers a unique opportunity to meet the engineers who have developed the Oracle B2B product. Please stop by at our booth to see cool demos on EDI X12, EDIFACT and SBRES (used in Airlines industry). We will also be showing integration with OSB, SOA Suite and BAM. Use this opportunity to see the product in action, learn, and get answers to your questions. We will be happy to meet you and hear about your B2B integration usecases and discuss our roadmap. The demo pod will be available at the Fusion Middleware Demo POD area on Monday, October 1 through Wednesday, October 3, 2012. Look forward to seeing you there! Happy OOW 2012!

    Read the article

  • iPhone SDK page flip and Page curl

    - by Andre
    I got the page flips and curls to work. I'll describe what happens... I build and Go The App opens in simulator I press a button and the page curls to page 2... but when it gets to page 2 the page drops down a bit. Why does this happen?

    Read the article

  • How switch UIViewController by flip from 3 controllers ?

    - by Sergey
    Hello, all. I've got next problem: i've got 3 UIViewController and need to switch controllers by UIModalTransitionStyleFlipHorizontal. Next code working fine: testController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:testController animated:YES]; where testController - next controller to switch, self - current controller. And when i've set 3rd controller - it's working fine, but i have problem with back to first controller - when i back to first controller - i can't go to second controller. 1 - 2 - 3 - 1 - it's working fine, but - 2 - don't show. what's mistake ?

    Read the article

  • Using Javascript to flip flop a textbox's readonly flag

    - by Velika
    I have a frame with several radio buttons where the user is supposed to select the "Category" that his Occupation falls into and then unconditionally also specify his occupation. If the user selects "Retired", the requirement is to prefill "Retired" in the "Specify Occupation" text box and to disable it to prevent it from being changed. The Specify Occupation text box should also no longer be a tab stop. If the user selects a radio button other than Retired the Specify Occupation text box should be enabled and once again in the normal tab sequence. Originally, I was setting and clearing the disabled property on the Specify occupation textbox, then I found out that, upon submitting the form, disabled fields are excluded from the submit and the REQUIRED validator on the Specify Occupation textbox was being raised because the textbox was being blanked out. What is the best way to solve this? My approach below was to mimic a disabled text box by setting/resetting the readonly attribute on the text box and changing the background color to make it appear disabled. (I suppose I should be changing the forecolor instead of teh background color). Nevertheless, my code to make the textbox readonly and to reset it doesn't appear to be working. function OccupationOnClick(sender) { debugger; var optOccupationRetired = document.getElementById("<%= optOccupationRetired.ClientId %>"); var txtSpecifyOccupation = document.getElementById("<%= txtSpecifyOccupation.ClientId %>"); var optOccupationOther = document.getElementById("<%= optOccupationOther.ClientId %>"); if (sender == optOccupationRetired) { txtSpecifyOccupation.value = "Retired" txtSpecifyOccupation.readonly = "readonly"; txtSpecifyOccupation.style.backgroundColor = "#E0E0E0"; txtSpecifyOccupation.tabIndex = -1; } else { if (txtSpecifyOccupation.value == "Retired") txtSpecifyOccupation.value = ""; txtSpecifyOccupation.style.backgroundColor = "#FFFFFF"; txtSpecifyOccupation.readonly = ""; txtSpecifyOccupation.tabIndex = 0; } } Can someone provide a suggest for the best way to handle this scenario and porovide a tweek to the code above to fix the setting/resetting on the readonly property?

    Read the article

  • flip a 1bpp .bmp image horizontally

    - by user576844
    I am trying to write a program containing two source files: main program written in C and assembly(x86 32 and 64) module callable from C. The C declaration for the assembly routine looks like this: void mirrorbmp1(void *img, int width, int height) The task involves Mirror/flipping a 1 bpp .BMP image horizontally while Handling any image width properly, not only multiples of 8. I am new to assembly programming and have very little idea about how i should do the ask. Any help would be appreciated.

    Read the article

  • CSplitterWnd flip between horizonal and vertical splitter?

    - by buttercup
    Hi, Suppose I have a splitter with 2 rows. -------- |        | -------- |        | -------- How do I make it to this --------- |    |    | |    |    | |    |    | --------- switch from horizontal split to vertical split without having to re-create the whole splitter? Code is: if (!m_wndSplitter.CreateStatic(this, 1, 2, WS_CHILD|WS_VISIBLE)) { TRACE0("Failed to create splitter window\n"); return FALSE; } if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CWnd), CSize(200, 100), NULL)) { TRACE0("Failed to create CView1\n"); return FALSE; } if (!m_wndSplitter.CreateView(0, 2, RUNTIME_CLASS(CWnd), CSize(500, 100), NULL)) { TRACE0("Failed to create CView2\n"); return FALSE; }

    Read the article

  • How can I "flip" an image using PHP?

    - by learner
    Here's what I've tried: $image = "images/20100609124341Chrysanthemum.jpg"; $degrees = 40; // Content type header('Content-type: image/jpeg'); // Load $source = imagecreatefromjpeg($filename); // Rotate $rotate = imagerotate($source, $degrees, 0); // Output imagejpeg($rotate); ...But I get no output. Can anyone tell me what's wrong with this?

    Read the article

  • How to do a JavaScript HTML 5 Canvas image "page flip" like you commonly see in Flash?

    - by Dr. Zim
    Has anyone tried recreating the page flip effect with images like you commonly see in Adobe Flash with JavaScript and HTML 5's canvas tag? Are there any frameworks or JQuery plug-ins that do this type of effect? The page flip in Flash allows you to grab a corner of the simulated book page and flip the page like you would flip a real book's page. I really want to learn how to do this with JavaScript and HTML 5's canvas tag, but not sure where to start nor what formulas would be necessary. Example page flip in flash

    Read the article

  • Hide uiview, but not it's subview?

    - by Malene
    Hi! I have an app where i add ViewB as a subview to ViewA... But the background of ViewB is clearColor, which means that I can see ViewA through ViewB! If I set viewA to be hidden, ViewB goes away too! I am making a "flip-transition" between the views, so I can't just remove ViewA and then add ViewB :-/ -Anybody got an idea about what I can do? Here's my code: [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mainTableView cache:YES]; [mainTableView addSubview:subTableView]; [UIView commitAnimations];

    Read the article

  • How to flip video feed that's presented upside down?

    - by Zuul
    Skype an other applications running under windows 7 Ultimate are presenting the video captured from the laptop built-in webcam upside down. I've tried many solution that I was able to find regarding issues like this, but to no avail. Some of the most relevant are discussed here: From Skype Support Network, the thread why is my video image of myself upside-down??? From ASUSTek Forums, the thread Built-in camera upside down Both present several potential solutions to this issue, but I've been unable to fix it for the laptop ASUS U6S. What I've already tried: Changing Drivers The driver that works must be the one from Windows, all others available from ASUS drivers either don't install or install but the webcam doesn't provide any video feed. This disallows all options that concern using an older driver or editing the .inf file as to manually adjust the settings. ASUS does not provide drivers for Windows 7, so I've used drivers from Windows Vista 32 Bit. Using the application manycam This application actually solves the issue (temporarily), but creates new ones: If I use the application to flip the video feed, Skype video call cease to work. This application doesn't save the settings, at least I wasn't able to find any way to save the settings I've used to flip the video feed. A computer restart brings all back to how it was, video feed upside down and if the application is still installed, Skype continues to fail on video calls. Regedit I've searched thru Windows Registry Editor as to find any reference to the webcam settings, hopping to find a key with the Flip parameter, since it's up to the driver to flip the image (by what I could ascertain from this problem). Couldn't find any reference to such settings, either they actually don't exist within the Windows Registry or they use some weird name that I could think off. System Configuration I was able to access the webcam system settings from the Windows Device Manager, but the tab that actually has the Image Rotation setting is always disabled. The same goes for the settings available from the Skype webcam options (that essentially is presenting the same settings as Windows Device Manager, just within a custom Skype pop-up). Question: How can I flip the video feed from the laptop's built-in webcam, as to properly see and broadcast the video?

    Read the article

  • Interview de David Booth et Jevgeni Kabanov de la société ZeroTurnaround au sujet de JRebel, leur ou

    Bonjour, David et Jevgueni, de la société ZeroTurnaround, éditeur de l'outil de productivité JRebel pour le développement Java, ont accepté de répondre à nos questions sur leur société et leur produit phare. Retrouvez l'interview en ligne : http://java.developpez.com/interview...around/jrebel/ Y-a-t'il d'autres questions que vous auriez aimé soumettre à ZeroTurnaround ? Voir aussi : ZeroTurnaroun...

    Read the article

  • Android page Curl animation

    - by Meymann
    Hi... Two questions: Is there a simple way to do the Curl page flipping animation? A Curl animation is animation of pages flipping, including the page above rolling and the shadows over the lower page. What is the recommended way to do a "gallery" that displays two pages at a time (just like a book)? Is it: Letting the adapter display a linear layout of two images at a time? (it won't let me show a page flipping over the other like a book) Using two pages, placing somehow one near the other, and then when it's time to animate -move the next two pages over? What is the better way that would enable displaying the left page flipping over the right page? Thanks Meymann

    Read the article

  • Android: ScrollView in flipper

    - by Manu
    I have a flipper: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/ParentLayout" xmlns:android="http://schemas.android.com/apk/res/android" style="@style/MainLayout" > <LinearLayout android:id="@+id/FlipperLayout" style="@style/FlipperLayout"> <ViewFlipper android:id="@+id/viewflipper" style="@style/ViewFlipper"> <!--adding views to ViewFlipper--> <include layout="@layout/home1" android:layout_gravity="center_horizontal" /> <include layout="@layout/home2" android:layout_gravity="center_horizontal" /> </ViewFlipper> </LinearLayout> </LinearLayout> The first layout,home1, consists of a scroll view. What should I do to distinguish between the flipping gesture and the scrolling? Presently: if I remove the scroll view, I can swipe across if I add the scroll view, I can only scroll. I saw a suggestion that I should override onInterceptTouchEvent(MotionEvent), but I do not know how to do this. My code, at this moment, looks like this: public class HomeActivity extends Activity { -- declares @Override public void onCreate(Bundle savedInstanceState) { -- declares & preliminary actions LinearLayout layout = (LinearLayout) findViewById(R.id.ParentLayout); layout.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (gestureDetector.onTouchEvent(event)) { return true; } return false; }}); @Override public boolean onTouchEvent(MotionEvent event) { gestureDetector.onTouchEvent(event); return true; } class MyGestureDetector extends SimpleOnGestureListener { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { // http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/ } } } Can anybody please guide me in the right direction? Thank you.

    Read the article

  • Workaround the flip queue (AKA pre-rendered frames) in OpenGL?

    - by user41500
    It appears that some drivers implement a "flip queue" such that, even with vsync enabled, the first few calls to swap buffers return immediately (queuing those frames for later use). It is only after this queue is filled that buffer swaps will block to synchronize with vblank. This behavior is detrimental to my application. It creates latency. Does anyone know of a way to disable it or a workaround for dealing with it? The OpenGL Wiki on Swap Interval suggests a call to glFinish after the swap but I've had no such luck with that trick.

    Read the article

  • How do I make a jumping dolphin rotate realistically?

    - by Johnny
    I want to program a dolphin that jumps and rotates like a real dolphin. Jumping is not the problem, but I don't know how to make the rotation. At the moment, my dolphin rotates a little weird. But I want that it rotates like a real dolphin does. How can I improve the rotation? public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Texture2D image, water; float Gravity = 5.0F; float Acceleration = 20.0F; Vector2 Position = new Vector2(1200,720); Vector2 Velocity; float rotation = 0; SpriteEffects flip; Vector2 Speed = new Vector2(0, 0); public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 720; } protected override void Initialize() { base.Initialize(); } protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); image = Content.Load<Texture2D>("cartoondolphin"); water = Content.Load<Texture2D>("background"); flip = SpriteEffects.None; } protected override void Update(GameTime gameTime) { float VelocityX = 0f; float VelocityY = 0f; float time = (float)gameTime.ElapsedGameTime.TotalSeconds; KeyboardState kbState = Keyboard.GetState(); if(kbState.IsKeyDown(Keys.Left)) { rotation = 0; flip = SpriteEffects.None; VelocityX += -5f; } if(kbState.IsKeyDown(Keys.Right)) { rotation = 0; flip = SpriteEffects.FlipHorizontally; VelocityX += 5f; } // jump if the dolphin is under water if(Position.Y >= 670) { if (kbState.IsKeyDown(Keys.A)) { if (flip == SpriteEffects.None) { rotation += 0.01f; VelocityY += 40f; } else { rotation -= 0.01f; VelocityY += 40f; } } } else { if (flip == SpriteEffects.None) { rotation -= 0.01f; VelocityY += -10f; } else { rotation += 0.01f; VelocityY += -10f; } } float deltaY = 0; float deltaX = 0; deltaY = Gravity * (float)gameTime.ElapsedGameTime.TotalSeconds; deltaX += VelocityX * (float)gameTime.ElapsedGameTime.TotalSeconds * Acceleration; deltaY += -VelocityY * (float)gameTime.ElapsedGameTime.TotalSeconds * Acceleration; Speed = new Vector2(Speed.X + deltaX, Speed.Y + deltaY); Position += Speed * (float)gameTime.ElapsedGameTime.TotalSeconds; Velocity.X = 0; if (Position.Y + image.Height/2 > graphics.PreferredBackBufferHeight) Position.Y = graphics.PreferredBackBufferHeight - image.Height/2; base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); spriteBatch.Draw(water, new Rectangle(0, graphics.PreferredBackBufferHeight -100, graphics.PreferredBackBufferWidth, 100), Color.White); spriteBatch.Draw(image, Position, null, Color.White, rotation, new Vector2(image.Width / 2, image.Height / 2), 1, flip, 1); spriteBatch.End(); base.Draw(gameTime); } } I changed my code a little. But I still have some trouble with the rotation. Here's the entire code. The dolphin looks at the wrong direction if I press the left or right key. For example, it looks down if I press the left key. What is wrong with the rotation? At the beginning, the dolphin looks at the left side, but after I pressed a key it just looks down or up. I deleted the "rotation += 0.01f;" lines in the code. Is that correct? public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Texture2D image, water; float Gravity = 5.0F; float Acceleration = 20.0F; Vector2 Position = new Vector2(1200,720); Vector2 Velocity; float rotation = 0; SpriteEffects flip; Vector2 Speed = new Vector2(0, 0); Vector2 prevPos; public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 720; } protected override void Initialize() { base.Initialize(); } protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); image = Content.Load<Texture2D>("cartoondolphin"); water = Content.Load<Texture2D>("background"); flip = SpriteEffects.None; } protected override void Update(GameTime gameTime) { float VelocityX = 0f; float VelocityY = 0f; float time = (float)gameTime.ElapsedGameTime.TotalSeconds; KeyboardState kbState = Keyboard.GetState(); if(kbState.IsKeyDown(Keys.Left)) { flip = SpriteEffects.None; VelocityX += -5f; } if(kbState.IsKeyDown(Keys.Right)) { flip = SpriteEffects.FlipHorizontally; VelocityX += 5f; } rotation = (float)Math.Atan2(Position.X - prevPos.X, Position.Y - prevPos.Y); prevPos = Position; // jump if the dolphin is under water if(Position.Y >= 670) { if (kbState.IsKeyDown(Keys.A)) { if (flip == SpriteEffects.None) { VelocityY += 40f; } else { VelocityY += 40f; } } } else { if (flip == SpriteEffects.None) { VelocityY += -10f; } else { VelocityY += -10f; } } float deltaY = 0; float deltaX = 0; deltaY = Gravity * (float)gameTime.ElapsedGameTime.TotalSeconds; deltaX += VelocityX * (float)gameTime.ElapsedGameTime.TotalSeconds * Acceleration; deltaY += -VelocityY * (float)gameTime.ElapsedGameTime.TotalSeconds * Acceleration; Speed = new Vector2(Speed.X + deltaX, Speed.Y + deltaY); Position += Speed * (float)gameTime.ElapsedGameTime.TotalSeconds; Velocity.X = 0; if (Position.Y + image.Height/2 > graphics.PreferredBackBufferHeight) Position.Y = graphics.PreferredBackBufferHeight - image.Height/2; base.Update(gameTime); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); spriteBatch.Draw(water, new Rectangle(0, graphics.PreferredBackBufferHeight -100, graphics.PreferredBackBufferWidth, 100), Color.White); spriteBatch.Draw(image, Position, null, Color.White, rotation, new Vector2(image.Width / 2, image.Height / 2), 1, flip, 1); spriteBatch.End(); base.Draw(gameTime); } }

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >