Skip to content

Conversation

PimsJay01
Copy link

I use function getTileAt of TMXLayer who accept as parameter a cc.Point or 2 integers. I found a bug present in almost every getters of class TMXLayer. If two integers are passed to function and x is equal to 0, function throw error "cc.TMXLayer.getTileAt(): pos should be non-null". Indeed, function to filter value was :

getTileAt: function (pos, y) {
    if (!pos) {
        throw new Error("cc.TMXLayer.getTileAt(): pos should be non-null");
    }
    ...
}

this check return true if :

  • null
  • undefined
  • NaN
  • empty string ("")
  • 0
  • false

I suppose that only null or undefined values have to throw error. So I suggest to change check as if(pos == null)

I also took the liberty to change every if(pos === undefined) by if(pos == null) to filter undefined and null values.

Is there any test for this class ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant