Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. In the touchMove event, decide a threshold which you consider the minimum distance the stick should move before you consider the direction pressed. In my previous example I used 0.2. You probably should have a setKey function that doesn't depend on Javascript event objects. Deal with the event object in the event handler itself rather than sending it to the setKey function. I'll work with what you've built, though, and create fake event objects. // A constantvar THRESHOLD = 0.2;// The event listenerstouchMove : function(data) { // Horizontal if(data.normalizeX < -THRESHOLD) { setKey({ keyCode : 37 }, true); } else if(data.normalizeX > THRESHOLD) { setKey({ keyCode : 39 }, true); } else { setKey({ keyCode : 37 }, false); setKey({ keyCode : 39 }, false); } // Vertical if(data.normalizeY < -THRESHOLD) { setKey({ keyCode : 40 }, true); } else if(data.normalizeY > THRESHOLD) { setKey({ keyCode : 38 }, true); } else { setKey({ keyCode : 40 }, false); setKey({ keyCode : 38 }, false); }},touchEnd : function(data) { // I assume when the player stops touching the joystick it goes back to neutral setKey({ keyCode : 37 }, false); setKey({ keyCode : 38 }, false); setKey({ keyCode : 39 }, false); setKey({ keyCode : 40 }, false);}
  2. You can use the direct sibling selector. In this example any <p> element that immediately follows an <h3> would be selected. p { text-indent: 2em;}h3 + p { text-indent: 0;}
  3. I don't know how your page is laid out, that's a CSS problem, not a Javascript problem. In order to fix that we need to know your HTML structure and all the CSS rules that are affecting it. You can use the second parameter of the animate() function to determine how many milliseconds it takes: $(".target").animate({ opacity : "0"}, 3000); // Duration: 3000 milliseconds (3 seconds)
  4. This jQuery plug-in meets your requirements: http://harvesthq.github.io/chosen/
  5. If you use Austin Hallock's script you just need to listen for the touchStart, touchMove and touchEnd events. You check the values of normalizedX and normalizedY to determine which direction to move. This is really simple but it's an example. I don't know what mechanics you use to move your character, and that makes a difference. GameController.init({ left: { type: 'joystick', joystick : { touchMove : function(data) { if(data.normalizedX < -0.2) { // Move the guy left } if(data.normalizedX > 0.2) { // Move the guy right } }, touchEnd : function(data) { // Set the velocity to zero } } }});
  6. When changing CSS properties, the values have to go between quotation marks like this: $("#wdShow").css({ color : "rgba(0,0,0,1.0)" }); jQuery's hover() method takes two parameters: The function to run when the mouse gets over the element and the function to run when the mouse leaves the element. You can use the .animate() method to make it change smoothly. $(".element").hover( function() { $(".target").animate({ opacity : "1" }); }, function() { $(".target").animate({ opacity : "0" }); }); To change its size, just determine what width and height you want to change it to and add that to the animate properties: $(".target").animate({ opacity : "1", width: "800px", height: "500px"});
  7. There's no way this plug-in can work in Internet Explorer 8 and under because it requires the <canvas> element which is not supported. The reason it won't work in Internet Explorer 9 is because it uses the requestAnimationFrame() function which isn't supported in versions earlier than 10. Because of the lack of a <canvas> element, the only possible workaround would be to program it in Flash. You can substitute the requestAnimationFrame() with a setTimeout() call and that should fix it for Internet Explorer 9, but you'll have to account for scope.
  8. You can put lots of data in the responseText, you just have to encode and decode it. You could, for example, separate values with commas: // PHPecho $row['a'] . ',' . $row['b'] . ',' . $row['c']; // Javascriptvar data = xmlhttp.responseText.split(",");alert(data[0]);alert(data[1]); One of the most common ways these days is to encode it in JSON. // PHPecho json_encode($row); // Javascriptvar data = JSON.parse(xmlhttp.reponseText);
  9. What is it doing and what did you expect it to do? Don't use mysqli_real_escape_string with prepared statements. Just forget that that function exists, it's only there for backwards compatibility with the old mysql library. Are you doing the exact same hashing procedure you did when adding the password to the database?
  10. You seem to have mistaken bind_result() for bind_params(). The syntax is different. bind_result() does not use the first parameter for data types. Read the manual: http://php.net/manual/en/mysqli-stmt.bind-result.php Don't put variables in the query string, put placeholders: 'SELECT salt,active FROM user WHERE username=?' If you put a variable in the query string you're missing half of the purpose of prepared statements.
  11. The order of the parameters tells it where to put things. Since "d" is the fourth parameter then it will be put where the fourth placeholder is.
  12. Which version of Internet Explorer were you testing in? Older versions of Internet Explorer had the line numbers for error messages all wrong and there really is no fix. Develop for modern browsers first, then tweak for Internet Explorer.
  13. Ingolme

    AJAX send request

    Is the database field of type INT? Try printing out the value instead of adding it to the database to see what you're getting. Use the network tab of the browser's developer tools to see what is being sent and what it being received.
  14. Ingolme

    Contact form

    Like I mentioned earlier, check the return value of the mail() function to see whether it succeeded or not: $success = mail($to,$subject,$txt,$headers);if($success) { // Show success message} else { // Show failure message}
  15. Ingolme

    Contact form

    Did you check the return value of the mail() function to see if it was true or false?
  16. You must not be familiar with bootstrap. Bootstrap is a CSS framework that abstracts the developer from the CSS. Learn more about it here: http://getbootstrap.com/ The person developing the page doesn't necessarily have to know what CSS bootstrap is using for each of the classes.
  17. Ingolme

    Contact form

    The server is not executing the PHP. That's all I can tell you from the symptoms you described. Check the URL in the address bar and confirm it's .php and not, perhaps, .php.html
  18. Ingolme

    Contact form

    That means your server isn't executing the PHP. Make sure your file has a .php extension and that the server actually supports PHP.
  19. You probably won't need a while() loop for your scripts. In my post I was just showing that you can have a variable that points to a different element each time but always has a nextElementSibling property and there's no need to know the ID of the sibling to reference it. In Javascript everything evaluates to true except for zero, null, an empty string and "undefined". If there is no element following the current one, then nextElementSibling will be null or undefined (I forget which) so it evaluates to false.
  20. You can always assign the element to a variable that can change. Here's an example using that technique: var element = document.getElementById("item1");while(element.nextElementSibling) { // Do something with the element // For example: element.style.color = "red"; // Next element: element = element.nextElementSibling;}
  21. They have to have taught you this in class, it's very important in computer science. It's about different systems for representing numbers. Any number can be represented as a sum of powers: http://en.wikipedia.org/wiki/Positional_notation The base of the power is the base of the numeral system. We use 10 in everyday life, but computers use base 2 (binary). Since binary numbers can get really long engineers use octal (base 8) and hexadecimal (base 16) to represent them. Because 8 and 16 are powers of 2, it's really easy to convert between base 2 and these bases. In octal each digit corresponds to 3 binary digits, in hexadecimal each digit corresponds to four binary digits.
  22. This probably is the problem: You have seven placeholders but, judging from the parameters you're passing to it, there are only six columns.
  23. "blob" is binary data (Binary Large OBject), which is like a string of characters with codes from 0 to 255. You would use this if you were storing data from binary files, like images and other media. "double" is for numbers with decimals. It's called that because it has double the precision of an ordinary floating point number. I don't think PHP actually has normal floats, just doubles.
×
×
  • Create New...