资源简介
基于cocos2d-x开发的瓦片地图demo,实现了双指缩放、地图拖拽、双击放大功能
代码片段和文件信息
//
// MapViewController.m
// Single View Test Project
//
// Created by Chiuan on 12-12-16.
// Copyright (c) 2012年 Chiuan. All rights reserved.
//
#import “MapViewController.h“
@interface MapViewController ()
@end
static MapViewController * instance;
@implementation MapViewController
@synthesize myMapView;
@synthesize locationManager;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
instance = self;
}
return self;
}
+(MapViewController*)getInstance{
return instance;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
//when open a mapcheck if the user confirm the location services
self.locationManager = [[CLLocationManager alloc] init];
NSLog(@“checking..“);
if(![CLLocationManager locationServicesEnabled]){
NSLog(@“location not open.“);
}
else{
NSLog(@“checking..OK“);
[self.locationManager setDelegate:self];
[self.locationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters]; //just use default accuracy
[self.locationManager setDistanceFilter:200];
[self.locationManager startUpdatingLocation];
}
NSLog(@“checking..end“);
self.myMapView = [[MKMapView alloc] initWithframe:self.view.bounds];
[self.myMapView setDelegate:self];
self.myMapView.mapType = MKMapTypeStandard;
self.myMapView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.myMapView setScrollEnabled:NO];
[self.myMapView setZoomEnabled:NO];
self.myMapView.showsUserLocation = TRUE;
[self.view addSubview:self.myMapView];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)dealloc{
[myMapView release];
[locationManager release];
[playerAnnotation release];
[super dealloc];
}
//show the player region
//this region need to change size by setting!
-(void)showPlayerRegion:(CLLocationDistance)paramRadious{
CLLocationCoordinate2D center = self.myMapView.userLocation.coordinate;
//Need to mark the center.
NSLog(@“center = %f %f“center.latitudecenter.longitude);
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(center paramRadious paramRadious);
MKCoordinateRegion newRegion = [self.myMapView regionThatFits:viewRegion];
[self.myMapView setCenterCoordinate:center animated:YES];
[self.myMapView setRegion:newRegion animated:YES];
//need to show player icon!
playerAnnotation = [[PlayerAnnotation alloc] initWithCoordinates:center title:@“Player“ subtitle:@“I‘m chiuan.“ mapView:self.myMapView];
[self.myMapView addAnnotation:playerAnnotation];
//add control of gesturer
UILongPressGestureRecognizer *lp
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-02-09 12:49 Cocos2dTest\
文件 6148 2013-02-09 22:12 Cocos2dTest\.DS_Store
目录 0 2013-02-09 22:12 __MACOSX\
目录 0 2013-02-09 22:12 __MACOSX\Cocos2dTest\
文件 82 2013-02-09 22:12 __MACOSX\Cocos2dTest\._.DS_Store
目录 0 2013-02-09 22:11 Cocos2dTest\.git\
文件 6148 2012-12-24 01:23 Cocos2dTest\.git\.DS_Store
目录 0 2013-02-09 22:12 __MACOSX\Cocos2dTest\.git\
文件 82 2012-12-24 01:23 __MACOSX\Cocos2dTest\.git\._.DS_Store
目录 0 2012-12-19 22:34 Cocos2dTest\.git\branches\
文件 15 2012-12-19 22:34 Cocos2dTest\.git\COMMIT_EDITMSG
文件 111 2012-12-19 22:34 Cocos2dTest\.git\config
文件 73 2012-12-19 22:34 Cocos2dTest\.git\desc
文件 23 2012-12-19 22:34 Cocos2dTest\.git\HEAD
目录 0 2012-12-19 22:34 Cocos2dTest\.git\hooks\
文件 452 2012-12-19 22:34 Cocos2dTest\.git\hooks\applypatch-msg.sample
文件 896 2012-12-19 22:34 Cocos2dTest\.git\hooks\commit-msg.sample
文件 189 2012-12-19 22:34 Cocos2dTest\.git\hooks\post-update.sample
文件 398 2012-12-19 22:34 Cocos2dTest\.git\hooks\pre-applypatch.sample
文件 1704 2012-12-19 22:34 Cocos2dTest\.git\hooks\pre-commit.sample
文件 4951 2012-12-19 22:34 Cocos2dTest\.git\hooks\pre-reba
文件 1239 2012-12-19 22:34 Cocos2dTest\.git\hooks\prepare-commit-msg.sample
文件 3611 2012-12-19 22:34 Cocos2dTest\.git\hooks\update.sample
文件 52264 2013-02-09 12:49 Cocos2dTest\.git\index
目录 0 2012-12-19 22:34 Cocos2dTest\.git\info\
文件 35 2012-12-19 22:34 Cocos2dTest\.git\info\exclude
目录 0 2013-02-09 22:12 __MACOSX\Cocos2dTest\.git\info\
文件 171 2012-12-19 22:34 __MACOSX\Cocos2dTest\.git\info\._exclude
目录 0 2012-12-19 22:34 Cocos2dTest\.git\logs\
文件 163 2012-12-19 22:34 Cocos2dTest\.git\logs\HEAD
目录 0 2012-12-19 22:34 Cocos2dTest\.git\logs\refs\
............此处省略1675个文件信息
相关资源
- cocos2d-x游戏源码236061
- cocos2d-x 别踩白块源码
- Cocos2d-x《大抗战》塔防射击游戏源代
- 基于cocos开发的飞机大战含素材资源
- 迷失航线-Cocos2d-x项目实战-射击类游戏
- BulletWar游戏源码coco2d-x开发 lua
- cocos2d-x塔防实现
- cocos2d-x游戏开发系列教程-坦克大战游
- cocos2d-x 2048小游戏源码+素材
- 坦克大战 类和图片资源
- 游戏:猫狗大作战
- Cocos2d-x滑雪游戏源码.zip
- cocos2d-x完整RPG游戏源代码(配套资源
- 用Cocos2d-x编写大富翁游戏源码,可联
- 植物大战僵尸源码
- TowerDefense cocos2d-x
- 瓦片地图切割工具
- Cocos2d-x3.2塔防游戏源代码
- 格斗横版过关类手游cocos2d-x lua源码
- Leaflet+heatmap加载本地google瓦片地图和
- Cocos Studio 创建帧动画
- 使用Cocos2d-X开发中国象棋
- Cocos2d-x时钟
- Cocos2d-x之Lua核心编程_PDF 高清 带索引
- Cocos2d-x高级开发教程:制作自己的《
- cocos2d-x半即时战斗rpg游戏demo源码
- cocos2d-x飞行射击类游戏整套素材资源
- 自己开发的瓦片地图器TMS64位系统用
- Cocos Creator中使用TiledMap教程资源
- cocos2d-x API大全中文版2016
评论
共有 条评论