Jump to content
  • Advertisement
Sign in to follow this  
Ryuske

Dynamic viewport similar to Pokemon

This topic is 2550 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!