• Advertisement
Sign in to follow this  

Dynamic viewport similar to Pokemon

This topic is 2403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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 the source in one of their demos:

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;
};


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
Sign in to follow this  

  • Advertisement