Bir MKMapView genelinde bir sprite animasyon

oy
2

OpenGL girmeden (Kuvars 2D Tamam):

  1. en Sanırım biraz sıvı şekilde bir harita üzerinde taşımak istediğiniz bir görüntüyü olduğunu varsayalım. Örneğin, bir uçağın bir görüntü harita üzerinde uçan. Bunun bir MKAnnotation, bir NSTimer kullanarak ve enlem / boylam değişim ve zamanlayıcı oranına oranı ile işe yaramaz yapmak başardık. Ancak, ben sonuç oldukça iyi ancak en ideal değildir varsayalım. Eğer daha iyi bir şekilde düşünebiliyor musunuz?

  2. Şimdi bu resmi (: animasyonlu gif düşünüyorum) canlandırılacak istiyorum diyelim. Her zamanki yapamaz UIImageViewbir dizi animationFramesben MKAnnotationView bir olduğunu içinde erişimi olan tüm çünkü UIImage. Siz bunu nasıl çözecek?

Ben 2. animationImages içeren haritanın üstünde bir UIImageView ele olabilir biliyoruz. Ancak, o zaman elle MapView bölge değiştikçe, uçak veya roket ya da her türlü hareketini çeviri gerçek dünyada kullanıcı hareketlere bağlı olarak, ya da kullanıcı (kaydırma Uygulamamda izin verilmez) yakınlaştırma işlemek gerekir.

Ne düşünüyorsun?

Oluştur 20/08/2009 saat 04:06
kaynak kullanıcı
Diğer dillerde...                            


1 cevaplar

oy
5

Ben 2. bir çözüm olduğunu çözdüm. Ben MKAnnotationView sınıflandırma ve bir subview (animasyon görüntüleri ile) UIImageView eklemek için bazı kod yazdım.

//AnimatedAnnotation.h

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>

@interface AnimatedAnnotation : MKAnnotationView
{
    UIImageView* _imageView;
    NSString *imageName;
    NSString *imageExtension;
    int imageCount;
    float animationDuration;
}

@property (nonatomic, retain) UIImageView* imageView;
@property (nonatomic, retain) NSString* imageName;
@property (nonatomic, retain) NSString* imageExtension;
@property (nonatomic) int imageCount;
@property (nonatomic) float animationDuration;


- (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier imageName:(NSString *)name imageExtension:(NSString *)extension imageCount:(int)count animationDuration:(float)duration
;

@end

//AnimatedAnnotation.m

#import "AnimatedAnnotation.h"

@implementation AnimatedAnnotation
@synthesize imageView = _imageView;
@synthesize imageName, imageCount, imageExtension,animationDuration;

- (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier imageName:(NSString *)name imageExtension:(NSString *)extension imageCount:(int)count animationDuration:(float)duration
{
    self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
    self.imageCount = count;
    self.imageName = name;
    self.imageExtension = extension;
    self.animationDuration = duration;
    UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%@0.%@",name,extension]];
    self.frame = CGRectMake(0, 0, image.size.width, image.size.height);
    self.backgroundColor = [UIColor clearColor];


    _imageView = [[UIImageView alloc] initWithFrame:self.frame];
    NSMutableArray *images = [[NSMutableArray alloc] init];
    for(int i = 0; i < count; i++ ){
        [images addObject:[UIImage imageNamed:[NSString stringWithFormat:@"%@%d.%@", name, i, extension]]];
    }


    _imageView.animationDuration = duration;
    _imageView.animationImages = images;
    _imageView.animationRepeatCount = 0;
    [_imageView startAnimating];

    [self addSubview:_imageView];

    return self;
}

-(void) dealloc
{
    [_imageView release];
    [super dealloc];
}


@end
Cevap 20/08/2009 saat 05:42
kaynak kullanıcı

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more