Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Help with sprites (hit counter)

Author
Message
Sh4d0xx
4
Years of Service
User Offline
Joined: 5th Dec 2014
Location: United Kingdom
Posted: 26th Apr 2016 10:00 Edited at: 26th Apr 2016 10:08
Hello,

1) I have a little unsolved mystery with sprites.

So far I've been working on sprites and can get them to animate and be interactive with no problems.

How ever I was wondering if there was a way (function) to make a hit counter that prints how many times the sprite has been hit ?

Basically something that stores how many times the sprite has been hit, displays it on the screen and can even be reset.

I know programmatically, this is something that shouldn't be overly complex.

It's just that I can't seem to find a way to go about it.

2) I also found something which I think is weird.

I have a timer on the screen that starts at 0 when I compile and run it on Windows.

However, when I broadcast it over WiFi, it doesn't seem to start at zero on my android phone (starts at 8 sometimes). I took the code from one of the examples bundled with AppGameKit v2.

The code for the timer:



Is this a bug ?

Your help will be much appreciated.
Thanks
isgltd (2014)
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Apr 2016 12:03
Quote: "when I broadcast it over WiFi, it doesn't seem to start at zero on my android phone"


When broadcasting, the timer starts when the emulator starts, not when your game starts.

There is an easy fix, at the start of your game...


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Sh4d0xx
4
Years of Service
User Offline
Joined: 5th Dec 2014
Location: United Kingdom
Posted: 26th Apr 2016 12:21
Quote: "When broadcasting, the timer starts when the emulator starts, not when your game starts.

There is an easy fix, at the start of your game..."


Thanks for that.
isgltd (2014)
Sh4d0xx
4
Years of Service
User Offline
Joined: 5th Dec 2014
Location: United Kingdom
Posted: 26th Apr 2016 12:31
UPDATE

I think I might have just found a solution to the sprite hit count (x+1 seems to work fine).

However there is another issue (very small issue).

When I click on the sprite, it displays the number increments (e.g. 1, 2, 3, 4, 5)

However each increment only appears on the screen for far less then a second.

So the issue here is printing the increments to permanently be displayed on the screen ?

Thanks
isgltd (2014)
Sh4d0xx
4
Years of Service
User Offline
Joined: 5th Dec 2014
Location: United Kingdom
Posted: 26th Apr 2016 12:48
UPDATE

Fixed it!

The blinking issue with the counter is because I placed the print command within the IF function.

It works if the Print command is placed outside the If function.

Thanks for your support.
isgltd (2014)
Sh4d0xx
4
Years of Service
User Offline
Joined: 5th Dec 2014
Location: United Kingdom
Posted: 26th Apr 2016 13:56
Quote: "When broadcasting, the timer starts when the emulator starts, not when your game starts.

There is an easy fix, at the start of your game..."



Just to inform you, I placed it just before the do loop, and it works perfectly when broadcast.

Thanks
isgltd (2014)

Login to post a reply

Server time is: 2019-11-17 15:30:08
Your offset time is: 2019-11-17 15:30:08