≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Change built-in behaviours?
Posted by:
(you are not logged in)
Enter the missing letter in: "Internation?l"
(you are not logged in)
Text:
[quote][b]Robo[/b] wrote: This might help...not sure, but was the basis for making my own keyboard input behavior in my game - change to suit your game as needed... /* <behavior jsname="behavior_Controls_Input" description="Keyboard/Mouse input"> </behavior> */ behavior_Controls_Input = function() { this.leftKeyDown = false; this.rightKeyDown = false; this.upKeyDown = false; this.downKeyDown = false; this.runKeyDown = false; }; behavior_Controls_Input.prototype.onAnimate = function(node) { // stop/move if (this.leftKeyDown || this.rightKeyDown || this.upKeyDown || this.downKeyDown) {ccbSetCopperCubeVariable("move",1);} else {ccbSetCopperCubeVariable("move",0);} // walk/run if (this.runKeyDown) {ccbSetCopperCubeVariable("run",1);} else {ccbSetCopperCubeVariable("run",0);} } behavior_Controls_Input.prototype.onKeyEvent = function(code, down) { // key codes (arrow): left=37, up=38, right=39, down=40 // key codes (WASD) : W=87, A=65, S=83, D=68 ccbSetCopperCubeVariable("keyPress",code); var run = ccbGetCopperCubeVariable("keyRun"); if (code == 37 || code == 65) { this.leftKeyDown = down; if (down) this.rightKeyDown = false; return true; } if (code == 39 || code == 68) { this.rightKeyDown = down; if (down) this.leftKeyDown = false; return true; } if (code == 38 || code == 87) { this.upKeyDown = down; if (down) this.downKeyDown = false; return true; } if (code == 40 || code == 83) { this.downKeyDown = down; if (down) this.upKeyDown = false; return true; } if (code == run) { this.runKeyDown = down; return true; }}[/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact