How do I Properly Fetch Products?

Get help using Construct 2

Post » Wed May 13, 2015 9:43 pm

Hey guys... it's me again :/ Sorry for these question spams, but i've been working on this project for a long time and every issue i've had i've written down and said to myself that once the main part is done i'd check and fix those issues, and there's almost none left!
-------------------------------------------------------------------------------------
So here's the deal: When you Fetch products from CocoonJS do you fetch the product on start of game or on start of layout(level)?

Here's an example to clarify: You're playing a shooter game and you run out of ammo so you go to the shop to buy ammo. Do you fetch the"ammo" product each time the layout (level)starts (which is many many times since you die a lot) or can you do a single fetch of the product "ammo" at the start of the game?

If it was a normal separate layout that started only once i'd do what i've always done and thats fetch on start of layout, but on a level layout that is bound to restart many times fetching each time the layout restarts seems quite wasteful of the user's resources, or does it not make a difference :o


Yeah hope this made some sort of sense lol, i can give more examples if you guys want :geek:
B
5
Posts: 48
Reputation: 319

Post » Thu May 14, 2015 10:30 am

I'm not sure what you mean by fetching..

Do you mean setting the global variable?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu May 14, 2015 12:42 pm

look at this image i took from a tutorial here on the forums:
https ://www.scirra . com/ images/articles/events_6.png

Here's what it says for those of you that are lazy to copy and paste:

On start of layout CocoonJS Fetch those products from store "productname"


Now put it this way, if it's a layout of a level where you die a lot (like flappy bird) the layout will restart every 10/20 seconds so is it a good idea to fetch the products each time the layout starts or can you fetch them once at game load (very first layout/main screen load)?
B
5
Posts: 48
Reputation: 319

Post » Thu May 14, 2015 12:55 pm

Why would you fetch them again after setting the global variable?
Would it make a difference?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu May 14, 2015 1:04 pm

I have no idea that's why im asking :P


Im afraid that if i set the "fetch product" to start of layout of the level that every time the player dies it will restart the layout and fetch the products which would waste resources and wouldn't be very efficient

What im asking is if fetching the product once (let's say at start of main screen layout) is okay and wont cause trouble, otherwise i'd fetch it every time the level layout restarts if that wont make a difference in performance
B
5
Posts: 48
Reputation: 319

Post » Thu May 14, 2015 1:47 pm

If there is no reason to fetch the product more than once, why do it?

What benefit will fetching the product a second time have?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu May 14, 2015 5:11 pm

i really dont know.. that's why im asking! lol

EDIT:
Ok guys so this is what i did, since i couldn't figure something else at all:

Instead of fetching the products on each start of layout the best thing would be to fetch the products only when, for example, the player is close/near the shop zone-area that way it wont fetch every single time the player dies but only when the player is in need of the shop(and that's when he's close to it)!

As far as my understanding goes this should fix the possible repetition issue but i'd still like to know if fetching a product once, at start of game for example, would have the same results as fetching it at the start of every layout :/
B
5
Posts: 48
Reputation: 319

Post » Thu May 14, 2015 10:21 pm

Let me clear your doubts:

1) Fetching of a product should be done in the same event sheet that is used to 'purchase' that product.

2) Fetching can be done at any point in time before the user could buy. For example: On start of layout, or even "On Purchase button pressed". But in this case, you should also use "is Fetched" then Purchase.

3) Only the last fetched product is purchased. So if you have multiple products, make sure you fetch each product with separate "On Button pressed" events before buying the corresponding product. It will not make sense to fetch all products together On start of layout, since only the last fetched product will be 'ready to be bought'.

Hope this helps :)
-Hasan
B
10
S
2
Posts: 109
Reputation: 982

Post » Fri May 15, 2015 9:22 pm

Hey hasan thanks for the reply !

I have fixed everything now! Any ideas on how to test if these babies actually work.. without money? :D

EDIT: just wanted to ask if Preloading Ads (banner/fullscreen) at the start of each layout is a bad idea as well?

(i preload ad on start of layout then show it then on close of layout i hide it and redo that eveytime the layout changes to another one)
B
5
Posts: 48
Reputation: 319


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 57 guests