Keyboard and Events.ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Keyboard and Events.ppt

Keyboard and Events Fall 2009 Simply displaying text // Step 1: Create the font using the Tool menu option // Step 2: Declare PFont variable PFont f; void setup() { size(200,200); // Step 3: Load Font f = loadFont( Albany-48.vlw ); } void draw() { background(255); textFont(f,16); // Step 4: Specify font to be used fill(0); // Step 5: Specify font color // Step 6: Display Text text ( Mmmmm ... Strings ... ,10,100); } What are Strings? String is a data type (like int or char) It stores collections of characters (i.e., chars) that are delineated by quotes. char letter =‘b’; String word = “this is more than one word”; Any character on the keyboard (including numbers) can be part of a String You try it! // Step 1: Create the font using the Tool menu option // Step 2: Declare PFont variable PFont f; void setup() { size(200,200); // Step 3: Load Font f = loadFont( “you fill this in ); } void draw() { background(255); textFont(f, you fill this in); // Step 4: Specify font fill(0); // Step 5: Specify font color // Step 6: Display Text String message = “you fill this in ; text (message,10,100); } What about the keyboard? Keyboard inputs can be used in many waysnot just for text The boolean variable keyPressed is true if a key is pressed and false if not. keyPressed is true as long as a key is held down Another example with keyPressed // Move a line while any key is pressed int x = 20; void setup() { size(100, 100); smooth(); strokeWeight(4); } void draw() { background(204); if (keyPressed == true) { // If the key is pressed x++; // add 1 to x } line(x, 20, x-60, 80); } You can also display text The key variable is of type char and stores the most recently pressed key But characters are really numbers Each character has a numerical value defined by the ASCII code Coded Keys Processing can also read the value from other keys such as the ar

文档评论(0)

zhaoxq + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档