≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Any better way of creating customizable mouse input?
Posted by:
(you are not logged in)
Enter the missing letter in: "Int?rnational"
(you are not logged in)
Text:
[quote][b]dekon_17[/b] wrote: I am trying to create a pretty customizable controls for my game. So far, it goes way better than I thought it would. However, there is one thing that kinda worrying me about how good it is made. Since I want to make controlls customizable to the point that you can bind mouse wheel to particular actions (controls), one thing makes some "problems" - mouse wheel handling. There is no "mouse wheel up" or "mouse wheel down", there is only "mouse wheel moved". I found the solution for that pretty easily, but now... I think it isn't really a good way of doing so (because of optimisation reasons). Here is how it implemented: [code]... if (this.BootUp == true) { // CV means "Control Variable". // It stores ID of a key or mouse event. this.Next = ccbGetCopperCubeVariable (this.CV_Next); this.Prev = ccbGetCopperCubeVariable (this.CV_Prev); if (this.Next == 1) this.NDelta = ccbGetCopperCubeVariable (this.CV_Next + ".dir"); if (this.Prev == 1) this.PDelta = ccbGetCopperCubeVariable (this.CV_Prev + ".dir"); // variable with ".dir" at the end stores wheel direction. // It can only be equal 1 or -1. this.BootUp = false; } ...[/code] This is where controls are being set for my weapons switch menu script. And there... There is how I made its handling: [code]behavior_BSGswitch.prototype.onMouseEvent = function (mouseEvent, mouseWheelDelta) { if (mouseEvent == this.Next && this.Next == 1) { // If mouse wheel delta and required delta are both negative or both positive, // the result will only be positive, or, in other words, higher than 0. // And that means that directions match to eachother. if (mouseWheelDelta / this.NDelta > 0) this.Dir = 1; } else if (mouseEvent == this.Next && this.Next != 1) this.Dir = 1; if (mouseEvent == this.Prev && this.Prev == 1) { if (mouseWheelDelta / this.PDelta > 0) this.Dir = -1; } else if (mouseEvent == this.Prev && this.Prev != 1) this.Dir = -1; }[/code] What makes me concerned here is that it probably becomes a bit... "Heavy"? I mean, I came to this solution in about 5 or 10 minutes, so, I don't think it is the best optimized one. Any thoughts about that? Or, possibly... any optimizations?[/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