• Content count

  • Joined

  • Last visited

About barbara

  • Rank

Recent Profile Visitors

404 profile views
  1. Physics Movement Is Gounded

    Are you using phaser? In that case i think that what you are looking for is: if(sprite.touching.down){ doSomething}
  2. Hi, I'm making platform games with phaser, and to do so i prepare my levels in inkscape, i give a label to each image so when i end it i finally get an .svg document with an x and a y for each labeled element. Then i replace and delete all the useless text with my code editor till i get it in a .json format so i can pass it to my game as a new level. Is a repetitive and boring work, i hate it. So now i'm thinking in write a little "program" or script to do it. What i really don't know is how to pass through a text that it isn't an html or a php. i would prefer to code it with js as is the language i know most, but i'm open to suggestions. I think it shouldn't be so difficult as is only gather some text and creating a new document, but i don't know where to start. Thanks!
  3. How to store levels passed in a wordpress site

    Did it! Finally i need to use ajax to load a php page with the conexion to the SQL DataBase and pass the variables in javascript throught the get method. In case anyone has the same problem... Many thanks for your Help! Couldn't do it without you!
  4. Finally i found the conditional code, but now i can't update my sql as i want, these is my code: <script> //Store data in browser cache var lastLevelEnabled; function dataInLocalStorage(){ if(localStorage.lastLevelEnabled){ lastLevelEnabled=localStorage.lastLevelEnabled; }else{ lastLevelEnabled =1;localStorage.lastLevelEnabled = lastLevelEnabled; } } </script> [insert_php] //check if the user is logged with wp code if(is_user_logged_in()){ echo "<script> console.log( 'there is a user logged' );</script>"; //This is how wp gets the user data $current_user = wp_get_current_user(); echo $current_user->user_email; //Connect to sql dataBase $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully".'<br/>'; //Select LastLevel in DataBase $result = mysqli_query($conn,"SELECT gnomeWishLastLevel FROM wp_users WHERE user_login=('$current_user->user_email')"); //Fetch result and show it $resultFetch = mysqli_fetch_array($result); echo $resultFetch[0].'<br/>'; //Here is where i'm trying to store somehow the localStorage in js code in php so i can compare it and store it (i'm doing this in a desperate way, cause if i update here my sql data base i will need to reload the page each time user pass a level) $localStorage =<script>localStorage.lastLevelEnabled</script>; // and here i get an error when trying to update the DataBase if($localStorage>$resultFetch[0]){ mysqli_query($conn,"UPDATE wp_users set gnomeWishLastLevel = localStorage.lastLevelEnabled WHERE user_login=('$current_user->user_email')"); } } [/insert_php] <script> function storeNewData(){ //This function is called from SelectLevelState.js, so every time i pass a level is stored in localStorage localStorage.lastLevelEnabled = lastLevelEnabled; document.getElementById("lastLevelEnabled").innerHTML = "lastLevelEnabled " +localStorage.lastLevelEnabled; //Now i need to store it in mySQL too. i've tried calling a php method but aparently i need ajax for this. } </script> While searching, all i found is that i can't do what i'm trying and that if i want to connect with sql once the page is loaded or call a php method from my js code, i need to do it through ajax. i hope i explained my self clearly, if not ask me, please. Any ideas?? Thanks!
  5. The localStorage works perfecty! Thanks! I'm now able to connect to my sql through php get the informaciĆ³n of a user in the new column for my levels and change it. But i'm stuck in i where hope is the last step. I wanna keep mataining my local Storage for the ones that aren't logged and if they are logged get the information from the sql data base. But i can't reach the conditional code for: if(isLogged){checkSql}else{checkLocalStorage}. I'm using the Ultimate Member plugin i was looking in the docs and i can't find the code for this. Any ideas? Maybe i'm looking at it from the wrong side... Many thanks again!!
  6. Hi BobF, Actually i want to have a login access so i can store each user data for using it and displaying it in each case. But maybe i can take it litlle by little and try to make work first what you told me, i'm still blocked in the same place, i don't know how to pass my data from my main.js where my phaser game is, to my localStorage, so i can keep it and store it in the browser cache, as you are telling me. I understand i can take data from within my wordpress post by using document.getElementById to display it in this same post, but i don't know how to take data from within the main.js wich contains my game and has my level and lives variables. many thanks!
  7. Hi o0Corps0o, Thanks for your answer! I was looking at it, and i think that i can make it work. But, i,m not sure how to pass the data. Inside my wordpress post i have a <div> tag and inside it runs my phaser game. So i need to pass the variables from a javascript file (where my variables are stored) to a php file (my wordpress post) or to pass it from a javascript direct to my sql database. As far as i found i can't do it directly. Do i need ajax to make it work? or i am missing something? Many thanks for your time!
  8. Hi, I'm writting a platform game in phaser, and i want it to have 30 levels. I wanna post them in a wordpress page and i really don't know how can i storage the data: levels passed, lifes left, etc... so i can use it in the wordpress site to show some "leves/icons" as completed and in my phaser game to get this informacion further than the cache data i can pass throught States. My programmer skills are few so i don't even know how to start. Anyone can tel me where to start looking? Many thanks!! Barbara
  9. images don't collide in the rigth place

    it's the character's hitbox!! I didn't try it, cause i was sure it was a problem with the clouds, my fault! the player image sometimes is out of the render zone... i don't know why, i'm going to try some things so i can fix it! many thanks for your time guys!
  10. images don't collide in the rigth place

    Here it is: //player this.player = this.add.sprite(5,599,"hombre", 0);; this.player.body.allowGravity =true; this.player.animations.add ("running", [2,3,4], 10, true); this.player.animations.add("jumping", [1]);; this.player.customParams ={}; this.player.body.gravity.y = 1000; And here i activate physics and set gravity:; = 2000;
  11. images don't collide in the rigth place

    Hi drhayes, Thankyou for you answer, i will keep this tool But i still can't figure out wich is the problem, i attach another image, so you can see it renders in the correct position, but i still can walk "in the air".
  12. images don't collide in the rigth place

    Hi shohan4556, I tried, but still happens the same... Hi Skeptron, this is the code for the collisions:, this.clouds);
  13. Hi, I'm writing a platform game in phaser, but the limits of the platforms don't seem to be the same as the limits of the image, so my player can keep walking "in the air" even when there's no platform under him. I`ve attached an image, as you can see there's no cloud under the player, but he`s standing on it anyway, he can walk this far untill fall to the platform below. Here is the "preload()" code part : this.load.image("cloud", "assets/cloud.png"); And here the "create()" code part: this.cloudsData =[ {"x":0 , "y":750}, {"x":200 , "y":600}, {"x":0 , "y":450}, {"x":200 , "y":300} ]; this.clouds =; this.clouds.enableBody = true; this.cloudsData.forEach(function(element){ this.clouds.create(element.x, element.y, "cloud"); }, this); this.clouds.setAll("body.immovable", true); this.clouds.setAll("body.allowGravity", false); I've tried changing the image with the same result, i think the code is wrong but i don't know where. Many thanks.