Djennxs

Members
  • Content Count

    6
  • Joined

  • Last visited

About Djennxs

  • Rank
    Newbie

Contact Methods

  • Twitter
    djennxs
  1. Hey guys, I have a problem with the "setSize" function in Phaser 1.1.5 Does anybody know the problem? Link: http://dennisvdwaag.nl/html5demo/ EDIT: I feel so dumb right now... Fixed it, thanks anyway.
  2. Yeah, I did actually. Still couldn't figure it out...
  3. Hey guys, Thansk for answering. I found my answer after I restarted my PC. Weird, but it worked.
  4. Goodmorning everybody, I have a problem with my camera view. For some reason it won't move more than 1 pixel after the square hits the end of de canvas. Source: https://db.tt/h5okv2PG Any idea?
  5. Hey guys! I just recently started screwing around with Phaser and it went great, up untill now... I opened my laptop and started up my XAMPP server to get back to work, then this happened (attached files). I have no idea what happened or what it is doing. Also, here is my code: <html><head> <title>HTML5</title> <script src="phaser.js"></script> <style> body{margin:0; position: absolute; width: 100%; height: 100%;} canvas{margin-left: 15%; margin-top: 8%;} </style> <script src="game.js"></script></head><body> Deaths: <span id="deaths"></span><br> Rounds: <span id="rounds"></span></body></html>window.onload = function(){ // var windowWidth = document.body.clientWidth; // var windowHeight = document.body.clientHeight; var deaths = -3; var game = new Phaser.Game(900,480,Phaser.CANVAS,"", {preload: onPreload, create:onCreate, update:onUpdate}); var theSquare; var xSpeed = 6; var jumpHeight = 70; var jumpWidth = 180; var jumpRotation = 180; var jumpTime = 0; var isJumping = false; var degToRad = 0.0174532925; var floorY = Array(460,230); var floorX; var currentFloor = 0; var floorHeight = 20; var levelStart = 0; var objectStart; var levelEnd = 900; var rounds = 0; function onPreload(){ game.load.image("square", "square.png"); game.load.image("floorsmall", "floorsmall.png"); game.load.image("floormedium", "floormedium.png"); game.load.image("floorbig", "floorbig.png"); } function onCreate(){ var floor1 = game.add.graphics(0,0); floor1.lineStyle(floorHeight, 0x440044, 1); for(i = 0; i < floorY.length; i++){ floor1.moveTo(levelStart, floorY[i] + floorHeight/2); floor1.lineTo(levelEnd, floorY[i] + floorHeight/2); } floorX = Array(game.add.sprite(objectStart,floorY[currentFloor]-game.cache.getImage("floorsmall").height,"floorsmall"), game.add.sprite(objectStart,floorY[currentFloor]-game.cache.getImage("floormedium").height,"floormedium"), game.add.sprite(objectStart,floorY[currentFloor]-game.cache.getImage("floorbig").height,"floorbig")); theSquare = game.add.sprite(levelStart,floorY[currentFloor]-game.cache.getImage("square").height/2,"square"); theSquare.anchor.setTo(0.5, 0.5); game.input.onDown.add(jump, this); if (currentFloor == 0){ objectStart = Array(250, 450, 650); for(i = 0; i < floorX.length; i++){ floorX[i].x = objectStart[i]; } } } function jump(){ if(!isJumping){ jumpTime = 0; isJumping = true; } } function collHandler(obj1, obj2){ if(game.physics.overlap(obj1, obj2)){ theSquare.x = levelStart; deaths = deaths + 1; document.getElementById('deaths').innerHTML = deaths; rounds = 0; } } function onUpdate(){ for(i = 0; i < floorX.length; i++){ collHandler(theSquare, floorX[i]); } var mod = currentFloor % 2; theSquare.x += xSpeed * (1 - 2 * mod); if(theSquare.x > levelEnd && mod == 0 || theSquare.x < levelStart && mod == 1){ currentFloor++; if(currentFloor > floorY.length - 1){ currentFloor = 0; } mod = currentFloor % 2; //WERKT NIET!!!!! if(theSquare.x == levelStart){ currentFloor = 0; rounds = rounds + 1; alert('ok'); document.getElementById('rounds').innerHTML = rounds; } isJumping = false; theSquare.rotation = 0; theSquare.x = levelEnd * mod + levelStart * (1 - mod); theSquare.y = floorY[currentFloor]-game.cache.getImage("square").height / 2; } if(isJumping){ var jumpFrames = jumpWidth / xSpeed; var degreesPerFrame = jumpRotation / jumpFrames * (1 - 2 * mod); var radiansPerFrame = (180 / jumpFrames) * degToRad; jumpTime++; theSquare.angle += degreesPerFrame; theSquare.y = floorY[currentFloor]-game.cache.getImage("square").height / 2 - jumpHeight * Math.sin(radiansPerFrame * jumpTime); if(jumpTime == jumpFrames){ isJumping = false; theSquare.y = floorY[currentFloor]-game.cache.getImage("square").height / 2; } } } function onRender(){ } }; // window.onresize = function(e){ // var theCanvas = document.querySelector('canvas'); // theCanvas.height = document.body.clientHeight + 'px'; // theCanvas.width = document.body.clientWidth + 'px'; // }It's not perfect, but it works... Well, worked. Anybody who has an idea?