Sign in to follow this  
Ryuske

Dynamic viewport similar to Pokemon

Recommended Posts

So i am working on a tile-based game like Pokemon at the moment (written in Javascript with the Crafty game engine), and I am not sure how to make a moving viewport. I understand the logic, but I'm not sure how to do it.

Thanks in advanced

Share this post


Link to post
Share on other sites
You're probably better off asking about it in their own forum, unless you're lucky enough that a person in here got experience using their engine.

I can see from [url="http://craftyjs.com/demos/isometric/game.js"]the source[/url] in one of their demos:
[code]
function scroll(e) {
var dx = base.x - e.clientX,
dy = base.y - e.clientY;
base = {x: e.clientX, y: e.clientY};
Crafty.viewport.x -= dx;
Crafty.viewport.y -= dy;
};
[/code]

which (as you can see) is the code to scroll during a mousepress. So to move the viewport, it looks like all you have to do is add or subtract from Crafty.viewport.x/y

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this