SlideShare uma empresa Scribd logo
1 de 21
Tiled para o
CreateJS
Hamilton Lima
2013
Definições
• Tiled – Ferramenta para edição de
mapas e fases e outras coisas
• CreateJS – Biblioteca Javascript para
criar jogos e visualizações interativas
Tiled em ação
• Criar Camadas
• Nomes fáceis
• Evitar acentos nos nomes
como tiled fala
com o
createJS ?
CreateJS
Tiled
JSON =
Javascript
object
notation
<script>
var pessoa = {
nome: "joao", idade: 34 };
alert(pessoa.nome);
</script>
cuidado
código
complicado !!
level1.json
level1.js
var data =
foi fácil,
cadê o resto
do código ?
Resumo dos passos
1. Converter arquivo JSON para JS
2. Criar spritesheet com imagens usadas
3. Percorrer lista de camadas e o array data
para desenhar cada camada
4. Criar um BitmapAnimation para cada tile e
chamar gotoAndStop
Converter arquivo JSON para JS, ou em
outras palavras colocar o conteúdo do
JSON em uma variável
level1.json
level1.js
passo 1
passo 2
Criar spritesheet com imagens usadas. este exemplo considera o
uso de somente um spritesheet no tiled, e monta um objeto
spritesheetData para montar o objeto spritesheet.
var spritesheetData = {
images: [map.tilesets[0].image],
frames: {
width:map.tilesets[0].tilewidth,
height:map.tilesets[0].tileheight
}
};
spriteSheet = new createjs.SpriteSheet(spritesheetData);
spriteSheet.addEventListener("complete", processTiles);
Dica :
processtiles somente é
executado quando a
criação do spritesheet é
concluida.
passo 3
Percorrer lista de camadas, se o tipo de camada
é tilelayer, percorre data para desenhar.
for(n in map.layers){
if( map.layers[n].type == 'tilelayer' ){
for(i in map.layers[n].data){
var tid = map.layers[n].data[i];
// passo 4 aqui
}
}
}
passo 4
Criar um BitmapAnimation para cada tile e chamar
gotoAndStop, assim conseguimos exibir somente uma
imagem do spritesheet, usando o identificador de tile
(tid) para indicar que imagem exibir.
for(i in map.layers[n].data){
var tid = map.layers[n].data[i];
var tile = new createjs.BitmapAnimation(spriteSheet);
tile.gotoAndStop(tid -1);
// outras coisas...
}
Acesse o exemplo
completo em :
http://goo.gl/gwjDK2
ou em : https://github.com/hamilton-lima/javascript-
samples/blob/master/json/tiled/level1a.html
fim.

Mais conteúdo relacionado

Destaque

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destaque (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Tiled para CreateJS

  • 2. Definições • Tiled – Ferramenta para edição de mapas e fases e outras coisas • CreateJS – Biblioteca Javascript para criar jogos e visualizações interativas
  • 3. Tiled em ação • Criar Camadas • Nomes fáceis • Evitar acentos nos nomes
  • 4.
  • 5. como tiled fala com o createJS ?
  • 6.
  • 8.
  • 10. <script> var pessoa = { nome: "joao", idade: 34 }; alert(pessoa.nome); </script>
  • 13. var data = foi fácil, cadê o resto do código ?
  • 14. Resumo dos passos 1. Converter arquivo JSON para JS 2. Criar spritesheet com imagens usadas 3. Percorrer lista de camadas e o array data para desenhar cada camada 4. Criar um BitmapAnimation para cada tile e chamar gotoAndStop
  • 15. Converter arquivo JSON para JS, ou em outras palavras colocar o conteúdo do JSON em uma variável level1.json level1.js passo 1
  • 16. passo 2 Criar spritesheet com imagens usadas. este exemplo considera o uso de somente um spritesheet no tiled, e monta um objeto spritesheetData para montar o objeto spritesheet. var spritesheetData = { images: [map.tilesets[0].image], frames: { width:map.tilesets[0].tilewidth, height:map.tilesets[0].tileheight } }; spriteSheet = new createjs.SpriteSheet(spritesheetData); spriteSheet.addEventListener("complete", processTiles);
  • 17. Dica : processtiles somente é executado quando a criação do spritesheet é concluida.
  • 18. passo 3 Percorrer lista de camadas, se o tipo de camada é tilelayer, percorre data para desenhar. for(n in map.layers){ if( map.layers[n].type == 'tilelayer' ){ for(i in map.layers[n].data){ var tid = map.layers[n].data[i]; // passo 4 aqui } } }
  • 19. passo 4 Criar um BitmapAnimation para cada tile e chamar gotoAndStop, assim conseguimos exibir somente uma imagem do spritesheet, usando o identificador de tile (tid) para indicar que imagem exibir. for(i in map.layers[n].data){ var tid = map.layers[n].data[i]; var tile = new createjs.BitmapAnimation(spriteSheet); tile.gotoAndStop(tid -1); // outras coisas... }
  • 20. Acesse o exemplo completo em : http://goo.gl/gwjDK2 ou em : https://github.com/hamilton-lima/javascript- samples/blob/master/json/tiled/level1a.html
  • 21. fim.