SlideShare a Scribd company logo
1 of 20
網路遊戲設計 Web Game Design 授課教師 江素貞
Chapter 5 Chat First Chat Project
Create Login UI 宣告LoginScreen類別(LoginScreen.as),於建構子中載入SWF檔 讀取檔案資訊 (loader為 Loader物件) loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getComponents); public function getComponents(e:Event):void 	{ 		var info:LoaderInfo = e.target as LoaderInfo; 		var loader:Loader = info.loader as Loader; 		var a:MovieClip = loader.getChildAt(0) as MovieClip; 		var myMC:MovieClip = a.getChildAt(0) as MovieClip; 		loader.x = stage.stageWidth / 2 - info.width/2;	//info內含影片片段Size 		loader.y = stage.stageHeight / 2 - info.height/2; 		myMC.name_txt.text = "player" + Math.round(10000 * Math.random()); 	}
Create Login Screen(Dispatch Message) ,[object Object],	public varlogin_btn:Button; 	 	public static varOK:String=“OK”;	//定義事件名稱 	public function getComponents(e:Event):void 	{ 		…… login_btn = myMC.login_btn; login_btn.addEventListener(MouseEvent.CLICK, onClick); 	} 	public function onClick(e:MouseEvent) 	{ dispatchEvent(new Event(OK)); 	}
Create Login UI(Listen Event) var login:LoginScreen = new LoginScreen(); login.addEventListener(LoginScreen.OK, onLoginToServer);
Chat
使用者清單與訊息傳送 ConnServer中,登入成功時建立Chat物件(將ElectroServer instance傳入),接手處理訊息工作 ChatScreen類別為顯示聊天畫面 載入完成時派送”OK”訊息 按下[send]按鈕時派送”MSG”訊息 Chat.as:處理訊息 顯示聊天畫面 收到”OK”訊息時,讓使用者進入預設的Lobby房間 進入房間後顯示自己的名字及玩家清單 收到”MSG”訊息時,傳送訊息 收到PublicMessageEvent訊息時, 顯示訊息
MessageType Properties UserListUpdateEvent: 房間內有新玩家進入時觸發 ZoneUpdateEvent:Zone裡有房間被創造出來時觸發 PublicMessageRequest PublicMessageEvent CreateRoomRequest JoinRoomEvent 				    ZoneUpdateEvent
Show Chat UI Chatconstrucor chatScreen= new ChatScreen(); addChild(chatScreen); chatScreen.addEventListener(ChatScreen.OK, onChatScreenReady); chatScreen.addEventListener(ChatScreen.MSG, onChat);
Enter Lobby Room private function JoinRoom(roomName:String):void { varcrr:CreateRoomRequest = new CreateRoomRequest(); crr.setRoomName(roomName); crr.setZoneName("chat"); es.send(crr); }
Who Am I ,[object Object]
Example:	The es is a ElectroServer instance. es.getUserManager().getMe().getUserName() ,[object Object]
getMe(): Gets User that represents you.,[object Object]
Show User List 加入房間成功時呼叫 showUserList() 接收到 UserListUpdateEvent 時呼叫 showUserList() es.addEventListener(MessageType.UserListUpdateEvent, 	"onUserListUpdate", this); 	public function onUserListUpdate(ev:UserListUpdateEvent) 	{ showUserList(); 	}
Send Public Message varpmr:PublicMessageRequest = new PublicMessageRequest(); pmr.setMessage(chatScreen.chatInput_txt.text); pmr.setRoomId(room.getRoomId()); pmr.setZoneId(room.getZoneId());			 es.send(pmr); ,[object Object],[object Object]
偵測使用者進入或離開 public function onUserListUpdate(ev:UserListUpdateEvent) { 	//ev提供相關函式,可取得造成user list變更的使用者資訊 	if (ev.getActionId() == UserListUpdateEvent.DeleteUser){ 		//使用者離開 	} 	if (ev.getActionId() == UserListUpdateEvent.AddUser) { 		//使用者進入 	} }
設定TextArea之文字顏色 private function appendMessage(msg:String, color:String="#000000") { varmsgStr:String = "<font color='" + color + "'>" + msg + "</font>"; chatScreen.chatList_txt.htmlText+=(msgStr); }
Show Room List private function showRoomList() { varrooms:Array = 	es.getZoneManager().getZoneByName("chat").getRooms(); chatScreen.room_list.removeAll(); 	for (vari in rooms) { varrm:Room = rooms[i] as Room; var lab=rm.getRoomName()+"("+rm.getUserCount()+")“; chatScreen.room_list.addItem( { label:lab, data:rm } ); chatScreen.room_list.sortItemsOn("label", "ASC");  	} }
加入房間 public function onChangeRoom(e:Event){ varrm:Room = chatScreen.room_list.selectedItem.data; 	if (rm.getUserCount() == rm.getCapacity()) { 		//房間已滿 	} 	else{ leaveCurrentRoom();		//離開房間 JoinRoom(rm.getRoomName()); 	} }
離開房間 private function leaveCurrentRoom() { varlc:LeaveRoomRequest = new LeaveRoomRequest(); lc.setRoomId( myRoom.getRoomId() ); lc.setZoneId( myRoom.getZoneId() );	 es.send(lc); } ,[object Object]

More Related Content

Viewers also liked

Новые вызовы традиционной журналистике: new media и user-generated content
Новые вызовы традиционной журналистике: new media и user-generated contentНовые вызовы традиционной журналистике: new media и user-generated content
Новые вызовы традиционной журналистике: new media и user-generated contentMarina Litvinovich
 
Questionnaire version finale
Questionnaire version finaleQuestionnaire version finale
Questionnaire version finaleHenrik Ørvad
 
Facebook et les osbl les meilleures pratiques
Facebook et les osbl les meilleures pratiquesFacebook et les osbl les meilleures pratiques
Facebook et les osbl les meilleures pratiquestacticdirect
 
Atelier conference 10 octobre - voyages caritatifs
Atelier conference 10 octobre - voyages caritatifsAtelier conference 10 octobre - voyages caritatifs
Atelier conference 10 octobre - voyages caritatifstacticdirect
 
Pages Fans, quelles interactions avec vos fans ? | Maxime Garrigues (X-prime ...
Pages Fans, quelles interactions avec vos fans ? | Maxime Garrigues (X-prime ...Pages Fans, quelles interactions avec vos fans ? | Maxime Garrigues (X-prime ...
Pages Fans, quelles interactions avec vos fans ? | Maxime Garrigues (X-prime ...Ooredoo Tunisie
 
Réseaux sociaux et entreprise : Risque ou opportunité ?
Réseaux sociaux et entreprise : Risque ou opportunité ?Réseaux sociaux et entreprise : Risque ou opportunité ?
Réseaux sociaux et entreprise : Risque ou opportunité ?Karim Bouras
 
Основы языка HTML для интернет-журналистов
Основы языка HTML для интернет-журналистовОсновы языка HTML для интернет-журналистов
Основы языка HTML для интернет-журналистовMarina Litvinovich
 
Cайты на основе принципа краудсорсинга
Cайты на основе принципа краудсорсингаCайты на основе принципа краудсорсинга
Cайты на основе принципа краудсорсингаMarina Litvinovich
 
О трансформации гражданской кампании по сбору подписей в социальную сеть
О трансформации гражданской кампании по сбору подписей в социальную сетьО трансформации гражданской кампании по сбору подписей в социальную сеть
О трансформации гражданской кампании по сбору подписей в социальную сетьMarina Litvinovich
 
Генпрокуратура нашла пособников террористов
Генпрокуратура нашла пособников террористовГенпрокуратура нашла пособников террористов
Генпрокуратура нашла пособников террористовMarina Litvinovich
 
Патент Грабового
Патент ГрабовогоПатент Грабового
Патент ГрабовогоMarina Litvinovich
 
Ресурсы для интернет журналиста
Ресурсы для интернет журналистаРесурсы для интернет журналиста
Ресурсы для интернет журналистаMarina Litvinovich
 
Люди, причастные к гибели в тюрьме юриста Сергея Магнитского
Люди, причастные к гибели в тюрьме юриста Сергея МагнитскогоЛюди, причастные к гибели в тюрьме юриста Сергея Магнитского
Люди, причастные к гибели в тюрьме юриста Сергея МагнитскогоMarina Litvinovich
 
Развитие киберактивизма в Гринпис-Россия
Развитие киберактивизма в Гринпис-РоссияРазвитие киберактивизма в Гринпис-Россия
Развитие киберактивизма в Гринпис-РоссияMarina Litvinovich
 
Социальные сети как новый общественный инструмент
Социальные сети как новый общественный инструментСоциальные сети как новый общественный инструмент
Социальные сети как новый общественный инструментMarina Litvinovich
 

Viewers also liked (18)

Новые вызовы традиционной журналистике: new media и user-generated content
Новые вызовы традиционной журналистике: new media и user-generated contentНовые вызовы традиционной журналистике: new media и user-generated content
Новые вызовы традиционной журналистике: new media и user-generated content
 
la promotion
la promotionla promotion
la promotion
 
Questionnaire version finale
Questionnaire version finaleQuestionnaire version finale
Questionnaire version finale
 
Facebook et les osbl les meilleures pratiques
Facebook et les osbl les meilleures pratiquesFacebook et les osbl les meilleures pratiques
Facebook et les osbl les meilleures pratiques
 
Atelier conference 10 octobre - voyages caritatifs
Atelier conference 10 octobre - voyages caritatifsAtelier conference 10 octobre - voyages caritatifs
Atelier conference 10 octobre - voyages caritatifs
 
Pages Fans, quelles interactions avec vos fans ? | Maxime Garrigues (X-prime ...
Pages Fans, quelles interactions avec vos fans ? | Maxime Garrigues (X-prime ...Pages Fans, quelles interactions avec vos fans ? | Maxime Garrigues (X-prime ...
Pages Fans, quelles interactions avec vos fans ? | Maxime Garrigues (X-prime ...
 
PowerPoint 2010
PowerPoint 2010PowerPoint 2010
PowerPoint 2010
 
Réseaux sociaux et entreprise : Risque ou opportunité ?
Réseaux sociaux et entreprise : Risque ou opportunité ?Réseaux sociaux et entreprise : Risque ou opportunité ?
Réseaux sociaux et entreprise : Risque ou opportunité ?
 
Опрос
Опрос Опрос
Опрос
 
Основы языка HTML для интернет-журналистов
Основы языка HTML для интернет-журналистовОсновы языка HTML для интернет-журналистов
Основы языка HTML для интернет-журналистов
 
Cайты на основе принципа краудсорсинга
Cайты на основе принципа краудсорсингаCайты на основе принципа краудсорсинга
Cайты на основе принципа краудсорсинга
 
О трансформации гражданской кампании по сбору подписей в социальную сеть
О трансформации гражданской кампании по сбору подписей в социальную сетьО трансформации гражданской кампании по сбору подписей в социальную сеть
О трансформации гражданской кампании по сбору подписей в социальную сеть
 
Генпрокуратура нашла пособников террористов
Генпрокуратура нашла пособников террористовГенпрокуратура нашла пособников террористов
Генпрокуратура нашла пособников террористов
 
Патент Грабового
Патент ГрабовогоПатент Грабового
Патент Грабового
 
Ресурсы для интернет журналиста
Ресурсы для интернет журналистаРесурсы для интернет журналиста
Ресурсы для интернет журналиста
 
Люди, причастные к гибели в тюрьме юриста Сергея Магнитского
Люди, причастные к гибели в тюрьме юриста Сергея МагнитскогоЛюди, причастные к гибели в тюрьме юриста Сергея Магнитского
Люди, причастные к гибели в тюрьме юриста Сергея Магнитского
 
Развитие киберактивизма в Гринпис-Россия
Развитие киберактивизма в Гринпис-РоссияРазвитие киберактивизма в Гринпис-Россия
Развитие киберактивизма в Гринпис-Россия
 
Социальные сети как новый общественный инструмент
Социальные сети как новый общественный инструментСоциальные сети как новый общественный инструмент
Социальные сети как новый общественный инструмент
 

Similar to Les 4 ppt

17 camera, media, and audio in windows phone 8.1
17   camera, media, and audio in windows phone 8.117   camera, media, and audio in windows phone 8.1
17 camera, media, and audio in windows phone 8.1WindowsPhoneRocks
 
Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Apps
Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash AppsOwasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Apps
Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Appsguestb0af15
 
Cutting edge HTML5 API you can use today (by Bohdan Rusinka)
 Cutting edge HTML5 API you can use today (by Bohdan Rusinka) Cutting edge HTML5 API you can use today (by Bohdan Rusinka)
Cutting edge HTML5 API you can use today (by Bohdan Rusinka)Binary Studio
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonRobert Nyman
 
How to implement camera recording for USB webcam or IP camera in C#.NET
How to implement camera recording for USB webcam or IP camera in C#.NETHow to implement camera recording for USB webcam or IP camera in C#.NET
How to implement camera recording for USB webcam or IP camera in C#.NETOzeki Informatics Ltd.
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - MozillaRobert Nyman
 
AIR 開發應用程式實務
AIR 開發應用程式實務AIR 開發應用程式實務
AIR 開發應用程式實務angelliya00
 
Using AIR for Mobile Development
Using AIR for Mobile DevelopmentUsing AIR for Mobile Development
Using AIR for Mobile DevelopmentVeronique Brossier
 
Virus Bulletin 2015: Exposing Gatekeeper
Virus Bulletin 2015: Exposing GatekeeperVirus Bulletin 2015: Exposing Gatekeeper
Virus Bulletin 2015: Exposing GatekeeperSynack
 
WebAPIs & WebRTC - Spotify/sthlm.js
WebAPIs & WebRTC - Spotify/sthlm.jsWebAPIs & WebRTC - Spotify/sthlm.js
WebAPIs & WebRTC - Spotify/sthlm.jsRobert Nyman
 
Abusing & Securing XPC in macOS apps
Abusing & Securing XPC in macOS appsAbusing & Securing XPC in macOS apps
Abusing & Securing XPC in macOS appsSecuRing
 
Flash Widget Tutorial
Flash Widget TutorialFlash Widget Tutorial
Flash Widget Tutorialhussulinux
 
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
JavaScript APIs - The Web is the Platform - .toster conference, MoscowJavaScript APIs - The Web is the Platform - .toster conference, Moscow
JavaScript APIs - The Web is the Platform - .toster conference, MoscowRobert Nyman
 
JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformRobert Nyman
 
20141030 html5j-firefox os-deviceapi
20141030 html5j-firefox os-deviceapi20141030 html5j-firefox os-deviceapi
20141030 html5j-firefox os-deviceapiNoritada Shimizu
 
BlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM Europe
BlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM EuropeBlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM Europe
BlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM EuropeMariano Carrizo
 
Skinning Android for Embedded Applications
Skinning Android for Embedded ApplicationsSkinning Android for Embedded Applications
Skinning Android for Embedded ApplicationsVIA Embedded
 

Similar to Les 4 ppt (20)

17 camera, media, and audio in windows phone 8.1
17   camera, media, and audio in windows phone 8.117   camera, media, and audio in windows phone 8.1
17 camera, media, and audio in windows phone 8.1
 
Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Apps
Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash AppsOwasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Apps
Owasp Wasc App Sec2007 San Jose Finding Vulnsin Flash Apps
 
Cutting edge HTML5 API you can use today (by Bohdan Rusinka)
 Cutting edge HTML5 API you can use today (by Bohdan Rusinka) Cutting edge HTML5 API you can use today (by Bohdan Rusinka)
Cutting edge HTML5 API you can use today (by Bohdan Rusinka)
 
Moustamera
MoustameraMoustamera
Moustamera
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla London
 
How to implement camera recording for USB webcam or IP camera in C#.NET
How to implement camera recording for USB webcam or IP camera in C#.NETHow to implement camera recording for USB webcam or IP camera in C#.NET
How to implement camera recording for USB webcam or IP camera in C#.NET
 
Power ai image-pipeline
Power ai image-pipelinePower ai image-pipeline
Power ai image-pipeline
 
Web APIs & Apps - Mozilla
Web APIs & Apps - MozillaWeb APIs & Apps - Mozilla
Web APIs & Apps - Mozilla
 
AIR 開發應用程式實務
AIR 開發應用程式實務AIR 開發應用程式實務
AIR 開發應用程式實務
 
Using AIR for Mobile Development
Using AIR for Mobile DevelopmentUsing AIR for Mobile Development
Using AIR for Mobile Development
 
Virus Bulletin 2015: Exposing Gatekeeper
Virus Bulletin 2015: Exposing GatekeeperVirus Bulletin 2015: Exposing Gatekeeper
Virus Bulletin 2015: Exposing Gatekeeper
 
WebAPIs & WebRTC - Spotify/sthlm.js
WebAPIs & WebRTC - Spotify/sthlm.jsWebAPIs & WebRTC - Spotify/sthlm.js
WebAPIs & WebRTC - Spotify/sthlm.js
 
Abusing & Securing XPC in macOS apps
Abusing & Securing XPC in macOS appsAbusing & Securing XPC in macOS apps
Abusing & Securing XPC in macOS apps
 
Flash Widget Tutorial
Flash Widget TutorialFlash Widget Tutorial
Flash Widget Tutorial
 
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
JavaScript APIs - The Web is the Platform - .toster conference, MoscowJavaScript APIs - The Web is the Platform - .toster conference, Moscow
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
 
JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the Platform
 
20141030 html5j-firefox os-deviceapi
20141030 html5j-firefox os-deviceapi20141030 html5j-firefox os-deviceapi
20141030 html5j-firefox os-deviceapi
 
BlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM Europe
BlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM EuropeBlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM Europe
BlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM Europe
 
Skinning Android for Embedded Applications
Skinning Android for Embedded ApplicationsSkinning Android for Embedded Applications
Skinning Android for Embedded Applications
 
IOMX in Android
IOMX in AndroidIOMX in Android
IOMX in Android
 

Recently uploaded

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 

Recently uploaded (20)

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 

Les 4 ppt

  • 1. 網路遊戲設計 Web Game Design 授課教師 江素貞
  • 2. Chapter 5 Chat First Chat Project
  • 3. Create Login UI 宣告LoginScreen類別(LoginScreen.as),於建構子中載入SWF檔 讀取檔案資訊 (loader為 Loader物件) loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getComponents); public function getComponents(e:Event):void { var info:LoaderInfo = e.target as LoaderInfo; var loader:Loader = info.loader as Loader; var a:MovieClip = loader.getChildAt(0) as MovieClip; var myMC:MovieClip = a.getChildAt(0) as MovieClip; loader.x = stage.stageWidth / 2 - info.width/2; //info內含影片片段Size loader.y = stage.stageHeight / 2 - info.height/2; myMC.name_txt.text = "player" + Math.round(10000 * Math.random()); }
  • 4.
  • 5. Create Login UI(Listen Event) var login:LoginScreen = new LoginScreen(); login.addEventListener(LoginScreen.OK, onLoginToServer);
  • 7. 使用者清單與訊息傳送 ConnServer中,登入成功時建立Chat物件(將ElectroServer instance傳入),接手處理訊息工作 ChatScreen類別為顯示聊天畫面 載入完成時派送”OK”訊息 按下[send]按鈕時派送”MSG”訊息 Chat.as:處理訊息 顯示聊天畫面 收到”OK”訊息時,讓使用者進入預設的Lobby房間 進入房間後顯示自己的名字及玩家清單 收到”MSG”訊息時,傳送訊息 收到PublicMessageEvent訊息時, 顯示訊息
  • 8. MessageType Properties UserListUpdateEvent: 房間內有新玩家進入時觸發 ZoneUpdateEvent:Zone裡有房間被創造出來時觸發 PublicMessageRequest PublicMessageEvent CreateRoomRequest JoinRoomEvent ZoneUpdateEvent
  • 9. Show Chat UI Chatconstrucor chatScreen= new ChatScreen(); addChild(chatScreen); chatScreen.addEventListener(ChatScreen.OK, onChatScreenReady); chatScreen.addEventListener(ChatScreen.MSG, onChat);
  • 10. Enter Lobby Room private function JoinRoom(roomName:String):void { varcrr:CreateRoomRequest = new CreateRoomRequest(); crr.setRoomName(roomName); crr.setZoneName("chat"); es.send(crr); }
  • 11.
  • 12.
  • 13.
  • 14. Show User List 加入房間成功時呼叫 showUserList() 接收到 UserListUpdateEvent 時呼叫 showUserList() es.addEventListener(MessageType.UserListUpdateEvent, "onUserListUpdate", this); public function onUserListUpdate(ev:UserListUpdateEvent) { showUserList(); }
  • 15.
  • 16. 偵測使用者進入或離開 public function onUserListUpdate(ev:UserListUpdateEvent) { //ev提供相關函式,可取得造成user list變更的使用者資訊 if (ev.getActionId() == UserListUpdateEvent.DeleteUser){ //使用者離開 } if (ev.getActionId() == UserListUpdateEvent.AddUser) { //使用者進入 } }
  • 17. 設定TextArea之文字顏色 private function appendMessage(msg:String, color:String="#000000") { varmsgStr:String = "<font color='" + color + "'>" + msg + "</font>"; chatScreen.chatList_txt.htmlText+=(msgStr); }
  • 18. Show Room List private function showRoomList() { varrooms:Array = es.getZoneManager().getZoneByName("chat").getRooms(); chatScreen.room_list.removeAll(); for (vari in rooms) { varrm:Room = rooms[i] as Room; var lab=rm.getRoomName()+"("+rm.getUserCount()+")“; chatScreen.room_list.addItem( { label:lab, data:rm } ); chatScreen.room_list.sortItemsOn("label", "ASC"); } }
  • 19. 加入房間 public function onChangeRoom(e:Event){ varrm:Room = chatScreen.room_list.selectedItem.data; if (rm.getUserCount() == rm.getCapacity()) { //房間已滿 } else{ leaveCurrentRoom(); //離開房間 JoinRoom(rm.getRoomName()); } }
  • 20.