Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Sprite motion sharing

Avatar

Level 3

Hi

I am thinking this is possible:

I would like to create a sprite for each user in a game and I need to allow these sprite's to be moved using startDrag.

Is it possible to share this information so that if player 1 moves their sprite - the movement shows up on player 2's screen?

Thanks

Oliver

btw: please try my chess game at http://www.happydaygames.com.au (any comments/suggestions are welcome)

3 Replies

Avatar

Level 2

Yes this is possible!

At the end of the day, the information that describes the position of a any game token is as follows: x, y, and ID. If you create custom VO that contains that information, and send a message containing that VO to the server, then you can update the token on all clients simultaneously.

A couple of gotchas: Use Message.registerClass to make sure your VO gets decoded properly so you don't have to reparse it, and make sure you wait for the message to come back from the server before you update even on the acting client's machine.

Avatar

Level 3

Thanks - I guess that is one way to do it. I managed to successfully do it by using a SharedProperty which shares the y position of the canvas.

The player that has control publishes to the property and the other player receives the y change and then moves the canvas (The change in y is picked up by the MOUSE_MOVE event).

I was also able to get the session for use within the class by using a public property of type IConnectSession. I am unsure if this is the the best way to get the session into the class - do you know if there is a better way to do this?

Avatar

Level 3

Hi Michael

I thought about your idea again. Am I correct in assuming that your solution would use RemoteObject with AMF messaging support? AFCS will be too expensive to run this kind of application so I am thinking of implementing AMF.

Thanks