简体   繁体   中英

Page Redirect When Div Activate

I have a tile based game, the tiles are made up of 25x30 divs 16x16px each. I have onscreen controls to move the character and when you click a direction the player id updates to the div corresponding with the arrow you clicked. Is it possible to load a new page when the player id is added to a certain div.

For example

<div id="player"><img src="assets/img/charcter/ash.png"/></div>
Player ID

<div id="13_5" class="mapsquare teleporttile"></div>
Teleport div

If I use the arrow keys to move my player onto the div with the teleportrile class, is it possible to then load a webpage in the same window? I cant think of anyway to do this thanks!

If I understand correctly you would like to switch to another page when the player reaches a certain tile, am I ok?

Why instead of changing the id of the div for the player's id don't you check if the tile class is a special one (ie teleporttile)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM