Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
good looking score counter? — Gideros Forum

good looking score counter?

keszeghkeszegh Member
edited April 2014 in General questions
good looking animated counter.. so i have to include such a thing in my game to count scores (maybe also new best time after a game) of the player, and wonder if others already have a class for that. or simply if you did such a thing, then how did you did it?
several solutions come to mind, which would be best, simplest, etc?:
1. fade out old score, fade in new score. problem is that if only last digit changes than this looks amateurish as all the other digits fade in/out too. is there a simple workaround for this (with some blending)?
1.b the same, except fading all the digits separately
2. rolling numbers (like in wordament), all digits again have to be separate, some rendertotextureing will be needed to clip half-visible numbers while tweening. this seems complicated enough, i'm sort of not motivated enough to do this, but if you have snippets/class and willing to share, then i'm interested
3. the difference of the new and prev score 'flies up and disappears' at the counter and then the score just changes to the new score in way 1,2, etc. or with no animation, just switch to the new score

there are two main usages, ingame counter and after each game in a series a summary of the results, i.e. it adds the point to the prev points. the two things might have a different best way to do, e.g. in the second case even 1. can be an ok solution.

Comments

  • hgvyas123hgvyas123 Guru
    edited April 2014 Accepted Answer
    This is the what i am using as score counter
     
    local myScore = TextField.new(myFont,"Score :- 0")
    myScore:setTextColor(0xffffff)
    myScore:setPosition(300,300)
    myScore.score = 0
    myScore.score1 = 0
    stage:addChild(myScore)
     
    function myScore:set(param, value)
     
    	if param=="score" then
    		myScore.score=value
     
    		myScore.score  = math.floor(myScore.score )
    		myScore:setText("Score :- ".. myScore.score)
    		myScore:setX(300)
    	else
    		TextField.set(self, param, value)
    	end
    end
     
    function myScore:get(param, value)
    	if param=="score" then
     
    		return myScore.score
    	end
     
     
    	return TextField.get(self, param, value)
    end
     
    stage:addEventListener(Event.MOUSE_DOWN,function()
    	myScore.score1 = myScore.score1 + 300
    	GTween.new(myScore,0.4,{score = myScore.score1})
    	--GTween.new(myScore,0.4,{alpha =.5})
    end,stage)
  • keszeghkeszegh Member
    edited April 2014
    @hgvyas123, nice!
    tweening score, that's so neat. i did not realize that's possible. and visually it is quite close to what i imagined.

    following the latest comments in the post you linked, instead of "stage.__super." shouldn't we have "TextField."? (although for me it works as it is now)
    [edit: if a reader does not understand this remark, the reason is that it is now changed in the code too.]

    thanks!
  • Yes it should have to be. this is the what usually happened when we make quick example by copy and paste ;)

    :)
  • you can change it in your first post, so that future reference is correct..

    of course it would be nice if there was a way in gideros to know what was the super function, but in our case we know it anyway, so it's not that important.

    and thanks
  • i accepted @hgyvas123's answer as it is quite enough for me,
    but if others have different approaches, please share your thoughts.
Sign In or Register to comment.