WebSockets: What do you want?

Post your work in progress addons and get feedback

Post » Sun Sep 08, 2013 8:56 am

I stopped the loop by setting key event values to 1 (leaving the initial dictionary settings at 0). I just imagined this representing 0 for false and 1 for true. Then the sprite works properly. But not only did the message to server loop stop, but now no messages are received at all; indicating that it's no longer executing the websocket text message sends that I added.

I keep scrolling through the beginners tutorial and documentation in an effort to get a hint. But beyond generalities ... like add events and actions, then set values for parameters, they don't seem to get into much detail.
B
6
S
1
Posts: 76
Reputation: 606

Post » Sun Sep 08, 2013 10:12 am

Why don't I have keyboard events? Wouldn't that be the most straight-forward way to do this?
B
6
S
1
Posts: 76
Reputation: 606

Post » Sun Sep 08, 2013 11:13 am

The mouse, keyboard as well as touch are all separate objects you have to add one by one.

Also if you get the ribbon on top to maximize you should see the debugger icon which is available to all versions on preview. Not sure what the keyboard shortcuts are.



newt2013-09-08 11:14:25
Image ImageImage
B
168
S
50
G
163
Posts: 8,221
Reputation: 105,061

Post » Sun Sep 08, 2013 11:23 am

I think I'm making progress. I deleted all the dictionary definitions from On Start of Layout and all the Simulate 8 Direction from dictionary key actions. I added Sprite 8Direction is moving event with a websocket text message action. Now the sprite action works and I get the text message at the server each time I move the sprite. I actually get the text message 7 times, each time I click an arrow; but it actually looks like one click of an arrow might respond with several movements in the same direction.

I've seen the instructions for drop-n-drag adding addons, but don't know where to find the mouse, keyboard, etc. to add them. I found them under templates, but those are not .c2.... files.
B
6
S
1
Posts: 76
Reputation: 606

Post » Sun Sep 08, 2013 11:33 am

8Direction is moving isn't specific. Seems like if I could get keyboard installed, it work ... could specify right, left, etc. with that and it might fire only once per trigger.
B
6
S
1
Posts: 76
Reputation: 606

Post » Sun Sep 08, 2013 11:54 am

OK, Keyboard installed. It's easy once you know how. Now I just have to figure out how to use it.
B
6
S
1
Posts: 76
Reputation: 606

Post » Sun Sep 08, 2013 12:00 pm

Perfect.
B
6
S
1
Posts: 76
Reputation: 606

Post » Sun Sep 08, 2013 12:01 pm

Time to switch over to what the input from the server should look like.
B
6
S
1
Posts: 76
Reputation: 606

Post » Sun Sep 08, 2013 12:30 pm

[QUOTE=newt] Well if the return string was already formatted to "{"c2dictionary":true,"data":{}}" then when you received the message you could just load it into the dictionary object, and compare known keys, or do a for each key.
I would assume there shouldn't be many issues reloading the dictionary that way.[/QUOTE]

Newt:

Could you give a more complete example of the JSON string? I think the only condition is that the string doesn't simulate clicking an arrow key. Since I use arrow keys (keyboard) to trigger sending the message to the server, seems like that would put it in an infinite loop.

If there's a manual section that gets into this detail, that would be great. But for starters, I could use any response except right, left, up, down arrow keys.
B
6
S
1
Posts: 76
Reputation: 606

Post » Sun Sep 08, 2013 12:44 pm

this sounds juicy...
B
81
S
32
G
23
Posts: 1,053
Reputation: 35,965

PreviousNext

Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests