HTML5 Canvas follow object

自闭症网瘾萝莉.ら 提交于 2019-12-25 05:28:11

问题


I'm making an HTML5 game and I'm new to this, My issue is that I'm making a 2D game and I have a background that is bigger than my canvas.

I need that when my main object moves the camera moves with it so new background parts appear? But also that the rest of the objects disappear when required.

A little example will be

http://www.realmofthemadgod.com

Thanks


回答1:


Here is a good example from Simon Sarris:

jsFiddle link

Ignore the line below - posting a jsFiddle link requires accompanying code - which is too long to post!

var showFiddle = true


来源:https://stackoverflow.com/questions/16972710/html5-canvas-follow-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!