≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
keycode events
Posted by:
(you are not logged in)
Enter the missing letter in: "Interna?ional"
(you are not logged in)
Text:
[quote][b]Guest[/b] wrote: @VP Here's an example of doing what you want in pure code (no actions/behaviors) if that might help you. Here's an example file: [url]https://files.catbox.moe/xvyy2n.zip[/url] Here's just the code: [code] var cube = ccbGetSceneNodeFromName("cubeMesh1"); // get cube node var startTime = Date.now(); // get ms when app starts var step = 250; // change to control flicker rate var interval = step; // interval to add step amount to var key; // var to hold key code var pressed = false; // boolean for key press or not // function to set/unset cube visible function flicker(node) { var a = ccbGetSceneNodeProperty(node, "Visible"); // get node // toggle visiblity if (a) { ccbSetSceneNodeProperty(node, "Visible", false); } else { ccbSetSceneNodeProperty(node, "Visible", true); } } // key down event function keyDown(keyCode) { key = keyCode; pressed = true; } // key up event function keyUp(keyCode) { key = keyCode; pressed = false; } // "game loop" function game() { var now = Date.now(); // ms when loop starts var timeMs = now - startTime; // current time if (timeMs >= interval) { if (key == 70 && pressed == true) { flicker(cube); // flicker the cube interval += step; // increment interval } else { ccbSetSceneNodeProperty(cube, "Visible", true); } } } // register key events ccbRegisterKeyDownEvent("keyDown"); ccbRegisterKeyUpEvent("keyUp"); // registers "game loop" ccbRegisterOnFrameEvent(game); [/code] You can control the flicker rate by changing the step variable to whatever you want. Works like Every Few Seconds Do Something behavior. If you have any questions I can answer them.[/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