Can you spot the problem?

Because I sure as heck cannot. These two classes are (for now) almost identical, they each reference different elements of a public enum, but that is just to set the value of a parameter (which defaults to 0.10 in both classes.

What I should see from each class is an animated tile (which in fact I do). the problem is those that are created by the “actorTILE” class run VERY SLOW and changing the speed parameter has no effect.

If I hand one of the actor ID values to the “animatedTILE” class instead. it animated at the proper speed

If I query the “speed” parameter in either or both class instances I get the appropriate value :frowning:

class animatedTILE : baseSKSpriteNode {
    required init?(coder: NSCoder) { fatalError("init(coder:) Animated Tile") }
    init(id:Int,at: CGPoint) {
        var speed      : CGFloat = 0
        var texNAME    = String(format:"%02x",id).uppercased()
        texNAME        = "tile$\(texNAME)"
        super.init(texture:SKTexture(imageNamed:texNAME),color:UIColor.clear,size:CGSize(width:tileSize,height:tileSize))
        location       = at
        zPosition      = 10
        self.tileID    = mapItems(rawValue: id)!
        print("AnimateTile \(self.tileID) : \(texNAME) at \(at)")
        self.canMove   = false
        self.canRotate = false
        self.canPickUp = false
        switch self.tileID {
            case .water    : speed=0.40
            case .teleport : speed=0.10
            case .fire     : speed=0.15
            case .exit     : speed=0.50
            case .force_floor_N,.force_floor_S,.force_floor_E,.force_floor_W , .force_floor_ALL : speed=0.2
            case .toggleWall_OPEN, .toggleWall_CLOSED, .trap                                    : speed=0.1
            case .key_red,.key_blue,.key_green,.key_yellow,.flippers,.suction_boots,.ice_skates,.fire_boots : self.canPickUp = true
            default        : speed = 0.10
        }
        self.setAnimations(name: texNAME,autoStart: true,speed:speed)
    }
}
class actorTILE : baseSKSpriteNode {
    required init?(coder: NSCoder) { fatalError("init(coder:) Animated Tile") }
    init(id:Int,at: CGPoint,_ dir:String ) {
        var texNAME    = String(format:"%02x",id).uppercased()
        texNAME        = "tile$\(texNAME)"
        super.init(texture:SKTexture(imageNamed:texNAME),color:UIColor.clear,size:CGSize(width:tileSize,height:tileSize))
        location       = at
        zPosition      = 10
        self.tileID    = mapItems(rawValue: id)!
        print("Actor \(self.tileID) : \(texNAME) at \(at)")
        self.canMove   = true
        self.canRotate = true
        self.canPickUp = false
        switch self.tileID {
            case .bug_fire_N  : speed = 0.10
            case .bug_N       : speed = 0.10
            case .pink_ball_N : speed = 0.10
            case .tank_N      : speed = 0.10
            case .glider_N    : speed = 0.10
            case .frog_N      : speed = 0.10
            case .walker_N    : speed = 0.10
            case .blob_N      : speed = 0.10
            case .centipede_N : speed = 0.10
                //
            case .CHIP_N      : speed = 0.10
            default           : speed = 0.10
        }
        // "frog" is shown in this app as "ghost" and is NOT animated

        if self.tileID != .frog_N && self.tileID != .CHIP_N {
            self.setAnimations(name: texNAME,autoStart: true,speed:speed)
        }
    }

STRANGE

I deleted the ACTOR class, copied the code from the animatedTILE and made the minor changes to enum values… and it works… and I STILL don’t see any differences…

I don’t see “var speed” in actorTILE. Am I missing it?

1 Like

THAT WAS IT… when I rebuilt the class, it came over in the code I copied…
originally it was not there, and inheriited from the Superclass (which was actually SKNode)