r80 PhoneGap sub-event bug

Bugs will be moved here once resolved.

Post » Wed Feb 29, 2012 8:53 pm

OK, had a bit of a play and created some new .capx files and most sub-events seem to be working now in r80.2.

It looks like it may only affect sub-events that are referencing a global variable. I'll have a think about how I can build this into a simple layout and post up.
B
31
S
11
G
7
Posts: 197
Reputation: 6,682

Post » Wed Feb 29, 2012 9:35 pm

...nope, it isn't that either!!! I'm narrowing it down now - looks like it's something to do with sub-events that reference a global variable that links through to a WebStorage value...
Hopefully I'll nail it soon.
B
31
S
11
G
7
Posts: 197
Reputation: 6,682

Post » Wed Feb 29, 2012 10:24 pm

@Ashley - Got it! It's when using the webstorage facility - that's what's causing the problem. It also does it in the preview mode, but I hadn't cleared my appcache before, so that's why it seemed to be working.

I've put together a quick capx here: http://dl.dropbox.com/u/58315465/2012-02_BugTest1.capx

I hope this capx explains it. Basically, when the character gets through the exit hole it should restart the layout, but I think something in the webstorage is now stopping it creating the value. I now don't think it was the sub-event that was the problem in the first place, I just happen to have webstorage events in my sub-events.

...I think I've created the capx the right way to show what's going on... essentially this is a roughcut of what is happening in my main project

Let me know if you need anything else, Ashley. Look forward to hearing your take.AndyWatson2012-02-29 22:32:42
B
31
S
11
G
7
Posts: 197
Reputation: 6,682

Post » Wed Feb 29, 2012 10:45 pm

You have to cast the webstorage's value.

By default, it is a string, and on start of layout you assign a string to a number.
Result, gametest will probably be 0 the whole time.

On start of layout add a int().

Also on event 7, you litteraly save the value "gametest" (and not the value OF gametest) as it is written in between quotes (string).

Finaly you have to consider that the first time that you run your game, the webstorage is empty.
Assigning its value on stratup will end up by giving you a value of 0 for gametest.

Here's a corrected and working capx

I changed the name of the webstorage key ("save_gametest" to "saved_gametest" as the first one was filled with a "gametest" that made the rest of the code not work).

The only bug was in the code, sorry.Kyatric2012-02-29 22:46:44
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Wed Feb 29, 2012 11:01 pm

Thanks Kyatric, I made a few errors in my example that aren't in my main game - it's been at least a month since I've written anything for web storage, so I'm a bit rusty.
I don't have the 'int' in my game, so I'll add and see if that sorts it.
It's been working the same way for at least the last three or four releases.
B
31
S
11
G
7
Posts: 197
Reputation: 6,682

Post » Wed Feb 29, 2012 11:42 pm

Yeeeeeaaaaaahhh!!!! Looks like adding "int" in front of the webstorage has got my game working again.

I've no idea why it used to work without the 'int' and now I need to include it to make things run. My game's been working the same way perfectly for some time and I have apps on the android market running that way with no problem.

Many, many thanks for helping me get this sorted, Kyatric, and apologies for the mess I made of my earlier capx example (not sure why I used a value of '1' as an example - all the initial values on my main game are '0', and I don't have the unwanted speech marks in the main game either).

Really appreciate you getting to the bottom of this AndyWatson2012-02-29 23:44:56
B
31
S
11
G
7
Posts: 197
Reputation: 6,682

Post » Thu Mar 01, 2012 1:24 am

No problem.
I believe it was already good design using the int() cast previously.

In r80.2 though, Ash made it a requirement as now, webstorage is only considered as a string.
Before the type of webstorage was more "blurry".


New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Previous

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 2 guests