Implementing "Retrievable Items"
-
- Posts: 204
- Joined: 22 Sep 2013, 23:33
Implementing "Retrievable Items"
Hello,I was wondering if you guys could help get me started on what I might need to acquire to have users able to get items just laying around in a room.
Re: Implementing "Retrievable Items"
I think it depends on how your game works. For example if the player must click on an item to collect it, or he has to move his avatar above it.
In the first case you can: (1) send a request to your Extension where (2) it gets validated (make sure the item is in the expected coordinates, is not being collected by other players, etc). Then (3) the item is assigned to the player (maybe you have an "inventory" data structure, backed by a database entry) and (4) an Extension response is sent to all the users in the Room so that (5) their clients can remove the item from the game environment.
Instead, in case the avatar walks over the item to be collected, it depends on how you handle the avatar and item position and their collision. If everything is handled on the client side, then you can follow the same steps described above. Otherwise if the Extension is in charge of detecting the collisions, you can skip the first two steps.
In the first case you can: (1) send a request to your Extension where (2) it gets validated (make sure the item is in the expected coordinates, is not being collected by other players, etc). Then (3) the item is assigned to the player (maybe you have an "inventory" data structure, backed by a database entry) and (4) an Extension response is sent to all the users in the Room so that (5) their clients can remove the item from the game environment.
Instead, in case the avatar walks over the item to be collected, it depends on how you handle the avatar and item position and their collision. If everything is handled on the client side, then you can follow the same steps described above. Otherwise if the Extension is in charge of detecting the collisions, you can skip the first two steps.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
-
- Posts: 204
- Joined: 22 Sep 2013, 23:33
Re: Implementing "Retrievable Items"
Bax wrote:I think it depends on how your game works. For example if the player must click on an item to collect it, or he has to move his avatar above it.
In the first case you can: (1) send a request to your Extension where (2) it gets validated (make sure the item is in the expected coordinates, is not being collected by other players, etc). Then (3) the item is assigned to the player (maybe you have an "inventory" data structure, backed by a database entry) and (4) an Extension response is sent to all the users in the Room so that (5) their clients can remove the item from the game environment.
Instead, in case the avatar walks over the item to be collected, it depends on how you handle the avatar and item position and their collision. If everything is handled on the client side, then you can follow the same steps described above. Otherwise if the Extension is in charge of detecting the collisions, you can skip the first two steps.
SO basically what your saying here is if I turned the dbExtension on for the simpleChat zone then coded an extension where I would put columns like in a DB like: item name, and a time stamp to see when the user picked it up (Optional part here), and then have the extensions pick up on the collisions by using the user variables? Just want to make sure I am understanding you here
Re: Implementing "Retrievable Items"
Yes, that could be a basic starting point.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
-
- Posts: 204
- Joined: 22 Sep 2013, 23:33
Re: Implementing "Retrievable Items"
Bax wrote:Yes, that could be a basic starting point.
Alright thanks Bax, I am going to leave this thread unsolved for now because I may have more related questions.
-
- Posts: 204
- Joined: 22 Sep 2013, 23:33
Re: Implementing "Retrievable Items"
Ninjaoninja2 wrote:Bax wrote:Yes, that could be a basic starting point.
Alright thanks Bax, I am going to leave this thread unsolved for now because I may have more related questions.
Okay Bax, I have one quick question I have got it to work to where I can click the item and the item shows up on my avatar but I now I want to be able to walk up to it, how would I do that? Here's my current code.on (release)
Code: Select all
{
var newCol = 2;
_root.smartfox.setUserVariables({col:newCol, init:true});
_root.myAvatar.disc.gotoAndStop(newCol);
}
Re: Implementing "Retrievable Items"
Sorry but this is generic Flash support. You will have to look for Flash tutorials to learn how to detect collisions.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Return to “SmartFoxServer 1.x Discussions and Help”
Who is online
Users browsing this forum: No registered users and 77 guests