문제

This is my class I am trying to create the following constructor for:

class StatsView(name: String, manager: AssetManager, statistics: Statistics) extends Node(name) with Control {
....

This is the object for which I am trying to use the constructor of Node

object Node {
  def apply(name: String) = new Spatial(name) with Node
  def apply() = new Spatial with Node
}

trait Node extends Spatial {

My issue is that Node is a trait causing this error message from the compiler:

trait Node is a trait; does not take constructor arguments

trait Node is a trait; does not take constructor arguments

class StatsView(name: String, manager: AssetManager, statistics: Statistics) extends Node(name) with Control {

Hope you can help me.

도움이 되었습니까?

해결책

The problem is that Node(name) is just a method call and so can't be in extends. You need to write the type like this:

class StatsView(name: String, manager: AssetManager, statistics: Statistics) extends 
  Spatial(name) with Node { ... }

My issue is that I need to call the super constructor of Node

Since Node isn't a class, it doesn't have a super constructor.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top