开发者

I have some problems related to Javascript and HTML5 Canvas element and PHP CURL within my game

开发者 https://www.devze.com 2023-03-12 03:07 出处:网络
I have made a game using HTML5 Canvas Element, Javascript for facebook. There are two problems I am facing.

I have made a game using HTML5 Canvas Element, Javascript for facebook. There are two problems I am facing.

PROBLEM 1

1.My game is inside an iframe in the facebook app so when I use the onkeydown even of Javascript and press down arrow key, the game works normally but the scrollbars go up and down. I have uploaded the game and set it up already. It can be found at: snake.

PROBLEM 2

2.I totally can't understand how to use the graph API, since I have no knowledge of cURL, for posting the score earned on the wall without asking the player since if I ask them just like "facebook wants me to" th开发者_StackOverflowe player can change it.


1. You must use some method to stop event from bubbling or captured by parent:

for IE

window.event.cancelBubble = true

For Firefox, Safari, Chrome, Opera

e.stopPropagation()
e.preventDefault()

For more info read this document: http://www.quirksmode.org/js/events_order.html

2. You need to use ajax to submit score from user browser, not from server, because of you will have not user's authentication's token/cookie which use to identify what's user submitting the score. If you use ajax then browser will automatically push cookie together with request then you don't care about that.

0

精彩评论

暂无评论...
验证码 换一张
取 消