Tilemaps In tilemap games, the graphics consist of a small number of images, called tiles, that align with each other Tilemap can be bigger than screen.

Slides:



Advertisements
Similar presentations
Tutorial 3 – Creating a Multiple-Page Report
Advertisements

Working with Profiles in IX1D v 3 – A Tutorial © 2006 Interpex Limited All rights reserved Version 1.0.
Chapter 3 – Web Design Tables & Page Layout
Lesson 7: Using Tables Courseware #: 3240
Working with Tables for Page Design – Lesson 41 Working with Tables for Page Design Lesson 4.
Lesson 15 Working with Tables
Chapter 3 Creating a Business Letter with a Letterhead and Table
Microsoft Excel. Click on “Start,” then “Microsoft Office Excel.”
Objectives © Paradigm Publishing, Inc. 1 Objectives.
FrontPage Express By John G. Summerville Ph.D.©, RN.
Excel Tutorial 1 Getting Started with Excel
Chapter 3 Setting Up A Document.
Chapter 6 Photoshop and ImageReady: Part II The Web Warrior Guide to Web Design Technologies.
Microsoft Word 2010 Lesson 1: Introduction to Word.
CREATING A MULTIPLE PAGE REPORT Presented by: Dr. Ennis-Cole.
Site Modules > Page Builder Access the Page Builder module through the Site Modules top navigation link. Access Page Builder from the Site Modules navigation.
Intermediate Level Course. Text Format The text styles, bold, italics, underlining, superscript and subscript, can be easily added to selected text. Text.
Add the word linked between the words or and information in the first line of the text. submit.
XP New Perspectives on Microsoft Office Excel 2003, Second Edition- Tutorial 3 1 Microsoft Office Excel 2003 Tutorial 3 – Developing a Professional- Looking.
Reporting Aesthetics An ACEware Webinar 1:00-2:00 pm February 14 th, 2008.
Graphics Standard Grade Computing. Graphics Package n A graphics package is another General Purpose Package. n It is used to draw pictures on the monitor.
Computer Literacy BASICS: A Comprehensive Guide to IC 3, 5 th Edition Lesson 15 Working with Tables 1 Morrison / Wells / Ruffolo.
 Insert a picture from a file  Move and delete images  Use the Picture Tools tab  Add styles, effects, and captions to images  Resize photos  Use.
Lesson 5: Using Tables.
XP Tutorial 7 New Perspectives on Microsoft Windows XP 1 Microsoft Windows XP Working with Graphics Tutorial 7.
‘ {] Chapter 2 (HW01) Getting Started with Windows 7.
‘ {] PowerPoint Presentation to Accompany GO! with Windows 7 Getting Started Chapter 2 Getting Started with Windows 7.
Dreamweaver CS4 Concepts and Techniques Chapter 7 Page Layout with Frames.
Microsoft Excel By: Dr. K.V. Vishwanath Professor, Dept. of C.S.E,
Adding User Interactivity – Lesson 51 Adding User Interactivity Lesson 5.
Microsoft Office Excel 2003 Tutorial 3 – Developing a Professional-Looking Worksheet.
Using Tiled. What is Tiled? It’s a level editor It allows game programmers to create their 2D game world with ease.
Chapter 12 FRAMES. HOW FRAMES WORK When you view a framed page in a browser, you are actually looking at several HTML documents at once. The key to making.
XP New Perspectives on Microsoft Word 2002 Tutorial 31 Microsoft Word 2002 Tutorial 3 – Creating a Multiple-Page Report.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 14 Tables.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
ACTIVINSPIRE TRAINING Tips and tools for creating Flipcharts on ActivInspire.
Review of last session Add text to your website Add text to your website Title Title Paragraph Paragraph Title and paragraph Title and paragraph Add photographs.
Working with Objects. Objectives Create an object Transform an object Arrange and lock an object Step and repeat an object Use Live Distribute Use the.
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
Chapter 6 Working with Patterns and Brushes. Objectives Use the Move command Create a pattern Design a repeating pattern Use the Pattern Options panel.
Basic Editing Lesson 2.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 15 Advanced Tables.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall. 1 Skills for Success with Microsoft ® Office 2007 PowerPoint Lecture to Accompany.
Chapter 4 Working with Frames. Align and distribute objects on a page Stack and layer objects Work with graphics frames Work with text frames Chapter.
© 2011 Delmar, Cengage Learning Chapter 3 Setting Up A Document.
Building the Events Components– Lesson 111 Building the Events Components Lesson 11.
Chapter 8: Plotting. After completing this Chapter, you will be able to use the following features: Planning the Plot Sheet Plotting Environments Plotting.
© 2010 Delmar, Cengage Learning Chapter 4 Working with Frames.
Lesson 6 Formatting Cells and Ranges. Objectives:  Insert and delete cells  Manually format cell contents  Copy cell formatting with the Format Painter.
© 2011 Delmar, Cengage Learning Chapter 4 Working with Frames.
Creating Tables LESSON 6 - #1.06 ESSENTIAL STANDARD #1 - UNDERSTAND WORD PROCESSING INDICATOR #6 – CREATING TABLES.
Key Applications Module Lesson 14 — Working with Tables Computer Literacy BASICS.
Introduction to Drafting and Design In order to begin our drawing we have to set the drawing limits or the paper size.
Video in Macromedia Flash (Optional) – Lesson 121 Video in Macromedia Flash (Optional) Lesson 12.
Introducing Dreamweaver. Dreamweaver The web development application used to create web pages Part of the Adobe creative suite.
XP Tutorial 3 Creating Animations. XP New Perspectives on Macromedia Flash MX Elements of Animation Layers are used to organize the content of.
1 Word Processing Intermediate Using Microsoft Office 2000.
Desktop Publishing Lesson 1 — Working with Documents.
Tables MOAC LESSON 6. Table  Arrangement of data made up of horizontal rows and vertical columns  Used to organize information.
Lesson 13 Tables. Overview Create a table. Key and edit text in tables. Select cells, rows, and columns. Edit table structures. Format tables and cell.
Graphical Output Basic Images.
Microsoft Office 2007-Illustrated
Shelly Cashman: Microsoft Word 2016
Working with Tabs and Tables
Unit 4: Using Spreadsheets to Make Economic Choices Lessons 20–26
Selection, cropping, Rotation & layers.
Tutorial 3 – Creating a Multiple-Page Report
Chapter Lessons Use the Macromedia Flash drawing tools
Lesson 15 Working with Tables
Presentation transcript:

Tilemaps In tilemap games, the graphics consist of a small number of images, called tiles, that align with each other Tilemap can be bigger than screen (we can scroll) The same tile can be used many times memory savings

Tilemaps Orthogonal tiles (ch 10) tiles are rectangular; most of the time, they will be square (easier to align) Isometric tiles (ch 11): orthogonal tile rotated 45 degrees ( diamond), then compressed vertically: 2D image but gives a 3D look

Tilemaps Orthogonal tiles can use perspective gives the illusion of depth gives the illusion of 3D (with 2D images) Example: See figure 10-2 page 245

Build the Tilemap Usually done with an editor Tiled (Qt) Map Editor is free and open source, supported by Cocos2D Tiled works with both orthogonal and isometric tiles, supports multiple layers

Build the Tilemap Tiled also enables you to add trigger areas (in the Object layer) something happens when a character enters an area event driven programming Could prevent character from entering the area, make a sound, define spawn locations, …

Build the Tileset We need a tileset to make a tilemap A tileset is an image containing multiple tiles with equal spacing it is special type of texture atlas (images have the same size) Can use Texture Packer for that

Build the Tileset Inside Texture Packer, set Sort By Name Tiled refers to individual tiles in the tileset by position and offset only it is important that the tiles in the tileset stay in the same position (if you sort them by name, they will)

Tiled (Qt) Map editor Creates TMX files TMX files are (natively) supported by Cocos2D TMX files use XML (you could even edit them with a text editor)

Tiled (Qt) Map editor Set the orientation, the map size (width X height), tile size (width and height) Map size = w tiles TIMES h tiles Tile size should be the same as the tile images (in the book example 32 X 32)

Tiled (Qt) Map editor You can also specify margin (from image border) and spacing (between tiles) If you used Texture Packer to make the tileset, use the same margin and spacing Default is 0

Tiled (Qt) Map editor There are 4 modes for editing the tilemap: Stamp Brush (draw current selection) Bucket Fill (fills areas of connected, identical tiles) Eraser (erases tiles) Rectangular Select (select a range of tiles, then use copy and paste)

Tiled (Qt) Map editor Can zoom: Command Key with + or – We will use mostly the Stamp Brush mode To add a layer, Layer add Tile Layer could have a layer for summer, and a layer for winter and switch between them

Tiled (Qt) Map editor Can also add an Object Layer Layer add Object Layer There are 2 types of objects: Regular objects: rectangles Tile objects: allow you to place a tile anywhere on the map without snapping on the grid

Tiled (Qt) Map editor Can use Rectangle objects to annotate the map with key locations: trigger areas, spawn points, forbidden areas, … We can: Select Objects, Insert Objects, and Insert Tile Objects Mostly done via clicking, dragging, right clicking

Tiled (Qt) Map editor We can edit the properties of objects, layers and tiles Right click properties menu item Could create a new tile layer (Layer add Tile Layer) and place the properties in that layer (Properties layer or event driven code)

Tiled (Qt) Map editor Example of a property: isWater Do not use too many layers could impact frame rate 2 to 4 layers should be sufficient

Using the TMX tilemap Bring both TMX tilemap and the accompanying tileset image files (there could be more than 1) into the resources folder

Magic of the TMX file Look at it; it uses XML Check the image file paths for correctness You can also see the layers and the objects You can even edit it if you want (for example change the path of the file names if they are wrong)

CCTMXTileMap class CCTMXTileMap *tileMap = [CCTMXTileMap CCTMXTileMap is a subclass of CCNode can add it as a child to current CCLayer [self addChild: tileMap z: -1 tag: TileMapNode];

CCTMXLayer class If we have built the tilemap using several layers in Tiled, then we can use the method layerName of CCTMXTileMap to retrieve a particular layer, based on its name (the name we gave the layer in Tiled) layerNamed returns a CCTMXLayer

CCTMXLayer CCTMXLayer *eventLayer = [tileMap Assuming we named a layer GameEventLayer in Tiled when we build the tilemap can be useful to detect things based on their properties

Things of interest We will probably want a method that converts a touch location (a CGPoint) to a tile location (tile row, tile column another CGPoint) -(CGPoint )tilePosFromLocation: touchLocation tileMap: tileMap;

Touch location to tile location The tilemap may have been scrolled upper left of screen may not be 0, 0 of tilemap (tilemap may be bigger than screen) Subtract tilemap position from touch location to get touch position with respect to tilemap Now convert to tile row and column

Touch location to tile location Scale for retina display if necessary using CC_CONTENT_SCALE_FACTOR( ) scaledTileWidth = tilemap.tileSize.width / CC_CONTENT_SCALE_FACTOR( ); Same for scaledTileHeight tile row = (int) ( position.x / scaledTileWidth );

Touch location to tile location Tile coordinates (0,0) is at top left corner not bottom left corner Tile column = (int) ( (tilemap.mapSize.height * tilemap.mapSize.height - position.y ) / scaledTileHeight );

Accessing properties Access a tile via its tileGID in order to check its properties GID = Global Identifier Location of a touch tile position tile GID properties

Tile GID Touch ccTouchesBegan called retrieve location of touch, assign to touchLocation CGPoint tilePos = [self tilePosFromLocation: touchLocation tileMap: tileMap]; int tileGID = [eventLayer tileGIDAt: tilePos];

Retrieving properties of a tile Use propertiesForGID method of CCTMXTileMap class; returns an NSDictionary (hashtable) NSDictionary *properties = [tileMap propertiesForGID: tileGID]; can loop through properties or access a particular property

Checking a property of a tile Use valueForKey method of NSDictionary class; returns an object NSString *isWaterProperty = [properties we can then test isWaterProperty and execute some code depending on its value

Other things of interest Retrieve a tile: in CCTMXLayer class, use method -(CCSprite *) tileAt: (CGPoint) tileCoord Note that tileAt: returns a CCSprite, which in turns can be treated as such, i.e. you can scale it, rotate it, change its opacity,..

Other things of interest Remove a tile: in CCTMXLayer class, use method -(void) removeTileAt: (CGPoint) tileCoord Set a tile: in CCTMXLayer class, use method (if a tile is already there, it will be removed and replaced) -(void) setTileGID: (int) gid at: (CGPoint) tileCoord