1 decade ago
by pfaulty
Trying out the entities pack and for the life of me cannot get the earthquake (first one I've tried) to trigger.
I have the trigger and entity linked in Weltmeister (names/keys w/line drawn). I have the require statements in main.js. I also have console.log statements throughout earthquake.js showing that it is triggered and it is being updated. However in game when I trigger the earthquake nothing happens in all 3 major browsers.
I've tried creating a fresh project using a combination of entity pack and jumpnrun and got the exact same result.
Here is what I'm seeing
http://dl.dropbox.com/u/34100180/GameProgramming/Test2/index.html
If you walk roughly 1 tile (16 pixels) a head you should trigger. I have it set to count down over 25 seconds so don't be alarmed if you see a lot going on in console.log
Its almost like ig.game.screen.x and ig.game.screen.y do nothing and since there is no documentation on them, I'm at a loss.
Could someone please help me figure out what is wrong? Thanks in advance.
They are documented
http://impactjs.com/documentation/class-reference/game#screen-x-screen-y
I have not looked into your problem but I have seen issues like this before. If I remember correclty its something to do with the screen position not being set. If you take a look at the camera class created by Dominic
http://impactjs.com/forums/help/screen-scrolling#post1978 add this in to your project I think the earthquake will then work. You should be able to see what the Camera class is doing to resolve the issue if you do not want to use Dominics Camera class.
1 decade ago
by pfaulty
Thanks for the reply Stuart. I looked into the forum link you sent but it is just a lengthy thread full of code that doesn't clearly lay out where this camera code is supposed to go. I followed along and created the code in my own project but found it hard to figure out what they meant at times. Did you put this 1 line of code in? Sure, but where does it go?
If the game works without camera code (remember I'm starting from jumpnrun code) and screen.x /screen.y are the "position of a window into the game world" then why do I need a camera in the first place?
What I'd do for a good tutorial or access to see how Biolab does it.
The standard earthquake plugin simply moves the screen.x and screen.y using some random values over time. If you are using the standard jumpnrun code you will see it uses a simple follow routine in the main update. This sets the screen.x and screen.y to the player position. Basically you have now cancelled out the earthquake.
To prove this simply remark out the screen updates in main which set the screen position to the player position. The screen will not scroll but you should see the earthquake effect.
If you want to use the camera class (which will allow the earthquake to work):
copy the camera javascript and place it in the same folder as your main.js, name it camera.js
in your main.js requires add 'game.camera',
setup a property in main.js named camera and set this to null by defualt
camera:null,
normally just before you load a level or in startup you need to setup the camera in main.js
this.camera = new Camera(ig.system.width /4, ig.system.height / 3,5);
this.camera.trap.size.x = ig.system.width / 3;
this.camera.trap.size.y = ig.system.height / 3;
this.camera.lookAhead.x = ig.ua.mobile ? ig.system.width / 6 :0;
after the level has loaded you need to setup some max values for the camera and also point it at your player. Normally in loadLevel.
this.camera.max.x = this.collisionMap.width * this.collisionMap.tilesize - ig.system.width;
this.camera.max.y = this.collisionMao.height * this.collisionMap.tilesize - ig.system.height;
this.camera.set(this.player);
in your main.js update you need to tell the camera to follow your player.
this.camera.follow(this.player);
that should be it, sorry for any typo's on the train at the moment.
Page 1 of 1
« first
« previous
next ›
last »